Fix dead thread

This commit is contained in:
Ivan Agosto 2024-04-09 22:59:56 -06:00
parent 8972fdc305
commit 1118c877d7
1 changed files with 10 additions and 8 deletions

View File

@ -16,16 +16,18 @@ object PlaybackSingleton {
var video: VideoModel? = null var video: VideoModel? = null
private var withMediaSession = false private var withMediaSession = false
fun setData(mediaItem: MediaItem, video: VideoModel): ExoPlayer { fun setData(mediaItem: MediaItem, video: VideoModel): ExoPlayer? {
if (this.player!!.isPlaying) { player?.let {
this.player!!.stop() if (it.isPlaying) {
it.stop()
}
it.setMediaItem(mediaItem)
// it.prepare()
this.video = video
return it
} }
this.player!!.setMediaItem(mediaItem)
this.player!!.prepare()
this.video = video return null
return this.player!!
} }
fun release() { fun release() {