Allow the user to rotate the player and fix resume playback
This commit is contained in:
parent
a212633eb2
commit
be385e2519
3 changed files with 9 additions and 2 deletions
|
@ -15,7 +15,7 @@
|
||||||
android:usesCleartextTraffic="true">
|
android:usesCleartextTraffic="true">
|
||||||
<activity
|
<activity
|
||||||
android:name=".PlayerActivity"
|
android:name=".PlayerActivity"
|
||||||
android:screenOrientation="landscape" />
|
android:screenOrientation="userLandscape" />
|
||||||
<activity
|
<activity
|
||||||
android:name=".MainActivity"
|
android:name=".MainActivity"
|
||||||
android:exported="true"
|
android:exported="true"
|
||||||
|
|
|
@ -45,9 +45,16 @@ class PlayerActivity : AppCompatActivity() {
|
||||||
|
|
||||||
override fun onPause() {
|
override fun onPause() {
|
||||||
super.onPause()
|
super.onPause()
|
||||||
|
viewModel.playWhenReady = viewModel.player.value?.playWhenReady == true
|
||||||
playerView.player?.playWhenReady = false
|
playerView.player?.playWhenReady = false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun onResume() {
|
||||||
|
super.onResume()
|
||||||
|
viewModel.player.value?.playWhenReady = viewModel.playWhenReady
|
||||||
|
hideSystemUI()
|
||||||
|
}
|
||||||
|
|
||||||
@Suppress("DEPRECATION")
|
@Suppress("DEPRECATION")
|
||||||
private fun hideSystemUI() {
|
private fun hideSystemUI() {
|
||||||
// These methods are deprecated but we still use them because the new WindowInsetsControllerCompat has a bug which makes the action bar reappear
|
// These methods are deprecated but we still use them because the new WindowInsetsControllerCompat has a bug which makes the action bar reappear
|
||||||
|
|
|
@ -32,7 +32,7 @@ constructor(
|
||||||
private val _navigateBack = MutableLiveData<Boolean>()
|
private val _navigateBack = MutableLiveData<Boolean>()
|
||||||
val navigateBack: LiveData<Boolean> = _navigateBack
|
val navigateBack: LiveData<Boolean> = _navigateBack
|
||||||
|
|
||||||
private var playWhenReady = true
|
var playWhenReady = true
|
||||||
private var currentWindow = 0
|
private var currentWindow = 0
|
||||||
private var playbackPosition: Long = 0
|
private var playbackPosition: Long = 0
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue