Allow the user to rotate the player and fix resume playback

This commit is contained in:
jarnedemeulemeester 2021-08-13 17:38:32 +02:00
parent a212633eb2
commit be385e2519
No known key found for this signature in database
GPG key ID: 60884A0C1EBA43E5
3 changed files with 9 additions and 2 deletions

View file

@ -15,7 +15,7 @@
android:usesCleartextTraffic="true">
<activity
android:name=".PlayerActivity"
android:screenOrientation="landscape" />
android:screenOrientation="userLandscape" />
<activity
android:name=".MainActivity"
android:exported="true"

View file

@ -45,9 +45,16 @@ class PlayerActivity : AppCompatActivity() {
override fun onPause() {
super.onPause()
viewModel.playWhenReady = viewModel.player.value?.playWhenReady == true
playerView.player?.playWhenReady = false
}
override fun onResume() {
super.onResume()
viewModel.player.value?.playWhenReady = viewModel.playWhenReady
hideSystemUI()
}
@Suppress("DEPRECATION")
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

View file

@ -32,7 +32,7 @@ constructor(
private val _navigateBack = MutableLiveData<Boolean>()
val navigateBack: LiveData<Boolean> = _navigateBack
private var playWhenReady = true
var playWhenReady = true
private var currentWindow = 0
private var playbackPosition: Long = 0