From 1118c877d775910547d407d77ec0313fac9c2a67 Mon Sep 17 00:00:00 2001 From: Ivan Agosto Date: Tue, 9 Apr 2024 22:59:56 -0600 Subject: [PATCH] Fix dead thread --- .../p2play/singletons/PlaybackSingleton.kt | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/org/libre/agosto/p2play/singletons/PlaybackSingleton.kt b/app/src/main/java/org/libre/agosto/p2play/singletons/PlaybackSingleton.kt index a6609ac..c299933 100644 --- a/app/src/main/java/org/libre/agosto/p2play/singletons/PlaybackSingleton.kt +++ b/app/src/main/java/org/libre/agosto/p2play/singletons/PlaybackSingleton.kt @@ -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() {