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
private var withMediaSession = false
fun setData(mediaItem: MediaItem, video: VideoModel): ExoPlayer {
if (this.player!!.isPlaying) {
this.player!!.stop()
fun setData(mediaItem: MediaItem, video: VideoModel): ExoPlayer? {
player?.let {
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 this.player!!
return null
}
fun release() {