Commit 08375f29 authored by Geoffrey Métais's avatar Geoffrey Métais

Fix dispatch during Mediaplayer.setMedia()

parent 561915d5
......@@ -73,11 +73,11 @@ class PlayerController(val context: Context) : IVLCVout.Callback, MediaPlayer.Ev
}
private var mediaplayerEventListener: MediaPlayerEventListener? = null
internal fun startPlayback(media: Media, listener: MediaPlayerEventListener) {
internal suspend fun startPlayback(media: Media, listener: MediaPlayerEventListener) {
mediaplayerEventListener = listener
resetPlaybackState(media.duration)
mediaplayer.setEventListener(null)
mediaplayer.media = media.apply { if (hasRenderer) parse() }
withContext(Dispatchers.IO) { mediaplayer.media = media.apply { if (hasRenderer) parse() } }
mediaplayer.setEventListener(this@PlayerController)
mediaplayer.setEqualizer(VLCOptions.getEqualizerSetFromSettings(context))
mediaplayer.setVideoTitleDisplay(MediaPlayer.Position.Disable, 0)
......
......@@ -307,7 +307,7 @@ class PlaylistManager(val service: PlaybackService) : MediaWrapperList.EventList
}
}
media.setEventListener(this@PlaylistManager)
withContext(Dispatchers.Main) { player.startPlayback(media, mediaplayerEventListener) }
player.startPlayback(media, mediaplayerEventListener)
player.setSlaves(media, mw)
newMedia = true
determinePrevAndNextIndices()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment