Handle config changes for video playback (#2754)

Fixes #2419
This commit is contained in:
Eva Tatarka 2022-11-07 13:57:13 -05:00 committed by GitHub
parent 5b5f48f9f3
commit 4bf541932a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 3 deletions

View file

@ -103,7 +103,8 @@
android:configChanges="orientation|screenSize" />
<activity
android:name=".ViewMediaActivity"
android:theme="@style/TuskyBaseTheme" />
android:theme="@style/TuskyBaseTheme"
android:configChanges="orientation|screenSize|keyboardHidden|screenLayout|smallestScreenSize" />
<activity
android:name=".components.account.AccountActivity"
android:configChanges="orientation|screenSize|keyboardHidden|screenLayout|smallestScreenSize" />

View file

@ -12,6 +12,7 @@ class ExposedPlayPauseVideoView @JvmOverloads constructor(
VideoView(context, attrs, defStyleAttr) {
private var listener: PlayPauseListener? = null
private var playing = false
fun setPlayPauseListener(listener: PlayPauseListener) {
this.listener = listener
@ -19,12 +20,18 @@ class ExposedPlayPauseVideoView @JvmOverloads constructor(
override fun start() {
super.start()
listener?.onPlay()
if (!playing) {
playing = true
listener?.onPlay()
}
}
override fun pause() {
super.pause()
listener?.onPause()
if (playing) {
playing = false
listener?.onPause()
}
}
interface PlayPauseListener {