mirror of
https://github.com/libre-tube/LibreTube.git
synced 2025-04-28 07:50:31 +05:30
fix: error toasts when switching between audio/video playback
This commit is contained in:
parent
4441a2bf4e
commit
b1a3a80ab3
@ -98,7 +98,7 @@ abstract class AbstractPlayerService : MediaLibraryService(), MediaLibrarySessio
|
||||
onServiceCreated(args)
|
||||
notificationProvider?.intentActivity = getIntentActivity()
|
||||
|
||||
startPlayback()
|
||||
if (::videoId.isInitialized) startPlayback()
|
||||
}
|
||||
}
|
||||
STOP_SERVICE_ACTION -> {
|
||||
@ -330,8 +330,6 @@ abstract class AbstractPlayerService : MediaLibraryService(), MediaLibrarySessio
|
||||
}
|
||||
}
|
||||
|
||||
fun isVideoIdInitialized() = this::videoId.isInitialized
|
||||
|
||||
/**
|
||||
* Stop the service when app is removed from the task manager.
|
||||
*/
|
||||
|
@ -79,8 +79,6 @@ open class OfflinePlayerService : AbstractPlayerService() {
|
||||
* Attempt to start an audio player with the given download items
|
||||
*/
|
||||
override suspend fun startPlayback() {
|
||||
if (!isVideoIdInitialized()) return
|
||||
|
||||
val downloadWithItems = withContext(Dispatchers.IO) {
|
||||
Database.downloadDao().findById(videoId)
|
||||
}!!
|
||||
|
@ -566,7 +566,7 @@ class PlayerFragment : Fragment(), OnlinePlayerOptions {
|
||||
}
|
||||
|
||||
binding.playImageView.setOnClickListener {
|
||||
playerController.togglePlayPauseState()
|
||||
if (::playerController.isInitialized) playerController.togglePlayPauseState()
|
||||
}
|
||||
|
||||
activity?.supportFragmentManager
|
||||
@ -628,7 +628,7 @@ class PlayerFragment : Fragment(), OnlinePlayerOptions {
|
||||
|
||||
binding.relPlayerBackground.setOnClickListener {
|
||||
// pause the current player
|
||||
playerController.pause()
|
||||
if (::playerController.isInitialized) playerController.pause()
|
||||
|
||||
// start the background mode
|
||||
playOnBackground()
|
||||
|
Loading…
x
Reference in New Issue
Block a user