Skip to content

Commit

Permalink
Merge pull request #6790 from Bnyro/master
Browse files Browse the repository at this point in the history
fix: error toasts when switching between audio/video playback
  • Loading branch information
Bnyro authored Nov 19, 2024
2 parents 1665b33 + b1a3a80 commit 0a0ac64
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ abstract class AbstractPlayerService : MediaLibraryService(), MediaLibrarySessio
onServiceCreated(args)
notificationProvider?.intentActivity = getIntentActivity()

startPlayback()
if (::videoId.isInitialized) startPlayback()
}
}
STOP_SERVICE_ACTION -> {
Expand Down Expand Up @@ -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.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}!!
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -566,7 +566,7 @@ class PlayerFragment : Fragment(), OnlinePlayerOptions {
}

binding.playImageView.setOnClickListener {
playerController.togglePlayPauseState()
if (::playerController.isInitialized) playerController.togglePlayPauseState()
}

activity?.supportFragmentManager
Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit 0a0ac64

Please sign in to comment.