fix: crash when videoId is unitialized

This commit is contained in:
Bnyro 2024-11-18 18:55:29 +01:00
parent 3d7cde97bc
commit 1dcc408c85
2 changed files with 4 additions and 0 deletions

View File

@ -307,6 +307,8 @@ abstract class AbstractPlayerService : MediaLibraryService(), MediaLibrarySessio
super.onDestroy() super.onDestroy()
} }
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.
*/ */

View File

@ -84,6 +84,8 @@ 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)
}!! }!!