fix app closing on pressing back (#565)

This commit is contained in:
Quickdesh 2022-05-03 05:28:55 +09:00 committed by GitHub
parent 856847f06e
commit b10a4c7fcf
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 7 deletions

View file

@ -809,9 +809,6 @@ class PlayerActivity :
player.destroy()
}
abandonAudioFocus()
if (packageManager.hasSystemFeature(PackageManager.FEATURE_PICTURE_IN_PICTURE) && Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
finishAndRemoveTask()
}
super.onDestroy()
}
@ -1129,11 +1126,13 @@ class PlayerActivity :
private fun eventPropertyUi(property: String, value: Boolean) {
when (property) {
"pause" -> {
if (!isFinishing) {
setAudioFocus(value)
updatePlaybackStatus(value)
}
}
}
}
override fun eventProperty(property: String) {}

View file

@ -67,8 +67,8 @@ class PlayerControlsView @JvmOverloads constructor(context: Context, attrs: Attr
PackageManager.FEATURE_PICTURE_IN_PICTURE,
) && Build.VERSION.SDK_INT >= Build.VERSION_CODES.O
}
binding.backArrowBtnLandscape.setOnClickListener { activity.finishAndRemoveTask() }
binding.backArrowBtnPortrait.setOnClickListener { activity.finishAndRemoveTask() }
binding.backArrowBtnLandscape.setOnClickListener { activity.onBackPressed() }
binding.backArrowBtnPortrait.setOnClickListener { activity.onBackPressed() }
// Lock and Unlock controls
binding.lockBtn.setOnClickListener { lockControls(true) }