mirror of
https://github.com/libre-tube/LibreTube.git
synced 2025-04-29 08:20:32 +05:30
Merge pull request #6790 from Bnyro/master
fix: error toasts when switching between audio/video playback
This commit is contained in:
commit
0a0ac64ad1
@ -98,7 +98,7 @@ abstract class AbstractPlayerService : MediaLibraryService(), MediaLibrarySessio
|
|||||||
onServiceCreated(args)
|
onServiceCreated(args)
|
||||||
notificationProvider?.intentActivity = getIntentActivity()
|
notificationProvider?.intentActivity = getIntentActivity()
|
||||||
|
|
||||||
startPlayback()
|
if (::videoId.isInitialized) startPlayback()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
STOP_SERVICE_ACTION -> {
|
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.
|
* 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
|
* Attempt to start an audio player with the given download items
|
||||||
*/
|
*/
|
||||||
override suspend fun startPlayback() {
|
override suspend fun startPlayback() {
|
||||||
if (!isVideoIdInitialized()) return
|
|
||||||
|
|
||||||
val downloadWithItems = withContext(Dispatchers.IO) {
|
val downloadWithItems = withContext(Dispatchers.IO) {
|
||||||
Database.downloadDao().findById(videoId)
|
Database.downloadDao().findById(videoId)
|
||||||
}!!
|
}!!
|
||||||
|
@ -566,7 +566,7 @@ class PlayerFragment : Fragment(), OnlinePlayerOptions {
|
|||||||
}
|
}
|
||||||
|
|
||||||
binding.playImageView.setOnClickListener {
|
binding.playImageView.setOnClickListener {
|
||||||
playerController.togglePlayPauseState()
|
if (::playerController.isInitialized) playerController.togglePlayPauseState()
|
||||||
}
|
}
|
||||||
|
|
||||||
activity?.supportFragmentManager
|
activity?.supportFragmentManager
|
||||||
@ -628,7 +628,7 @@ class PlayerFragment : Fragment(), OnlinePlayerOptions {
|
|||||||
|
|
||||||
binding.relPlayerBackground.setOnClickListener {
|
binding.relPlayerBackground.setOnClickListener {
|
||||||
// pause the current player
|
// pause the current player
|
||||||
playerController.pause()
|
if (::playerController.isInitialized) playerController.pause()
|
||||||
|
|
||||||
// start the background mode
|
// start the background mode
|
||||||
playOnBackground()
|
playOnBackground()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user