Merge pull request #6790 from Bnyro/master

fix: error toasts when switching between audio/video playback
This commit is contained in:
Bnyro 2024-11-19 14:08:18 +01:00 committed by GitHub
commit 0a0ac64ad1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 3 additions and 7 deletions

View File

@ -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.
*/

View File

@ -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)
}!!

View File

@ -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()