mirror of
https://github.com/libre-tube/LibreTube.git
synced 2025-04-29 00:10:32 +05:30
fix: crash when closing player before video started
This commit is contained in:
parent
994bebd8c4
commit
69f4c471c8
@ -93,6 +93,12 @@ class AudioPlayerFragment : Fragment(), AudioPlayerOptions {
|
||||
if (isOffline) OfflinePlayerService::class.java else OnlinePlayerService::class.java,
|
||||
bundleOf()
|
||||
) {
|
||||
if (_binding == null) {
|
||||
it.sendCustomCommand(AbstractPlayerService.stopServiceCommand, Bundle.EMPTY)
|
||||
it.release()
|
||||
return@startMediaService
|
||||
}
|
||||
|
||||
playerController = it
|
||||
handleServiceConnection()
|
||||
}
|
||||
|
@ -458,6 +458,12 @@ class PlayerFragment : Fragment(), OnlinePlayerOptions {
|
||||
VideoOnlinePlayerService::class.java,
|
||||
bundleOf(IntentData.playerData to playerData)
|
||||
) {
|
||||
if (_binding == null) {
|
||||
playerController.sendCustomCommand(AbstractPlayerService.stopServiceCommand, Bundle.EMPTY)
|
||||
playerController.release()
|
||||
return@startMediaService
|
||||
}
|
||||
|
||||
playerController = it
|
||||
playerController.addListener(playerListener)
|
||||
}
|
||||
@ -847,11 +853,13 @@ class PlayerFragment : Fragment(), OnlinePlayerOptions {
|
||||
|
||||
handler.removeCallbacksAndMessages(null)
|
||||
|
||||
playerController.removeListener(playerListener)
|
||||
playerController.pause()
|
||||
if (::playerController.isInitialized) {
|
||||
playerController.removeListener(playerListener)
|
||||
playerController.pause()
|
||||
|
||||
playerController.sendCustomCommand(AbstractPlayerService.stopServiceCommand, Bundle.EMPTY)
|
||||
playerController.release()
|
||||
playerController.sendCustomCommand(AbstractPlayerService.stopServiceCommand, Bundle.EMPTY)
|
||||
playerController.release()
|
||||
}
|
||||
|
||||
if (PlayerHelper.pipEnabled) {
|
||||
// disable the auto PiP mode for SDK >= 32
|
||||
|
Loading…
x
Reference in New Issue
Block a user