@@ -9,7 +9,6 @@ import androidx.media3.common.MediaItem
99import androidx.media3.common.MediaItem.SubtitleConfiguration
1010import androidx.media3.common.MimeTypes
1111import androidx.media3.common.Player
12- import androidx.media3.common.util.Log
1312import androidx.media3.datasource.DefaultDataSource
1413import androidx.media3.exoplayer.hls.HlsMediaSource
1514import com.github.libretube.R
@@ -160,13 +159,12 @@ open class OnlinePlayerService : AbstractPlayerService() {
160159 }
161160
162161 withContext(Dispatchers .Main ) {
163- playAudio(timestampMs)
162+ setStreamSource()
163+ configurePlayer(timestampMs)
164164 }
165165 }
166166
167- private fun playAudio (seekToPositionMs : Long ) {
168- setStreamSource()
169-
167+ private fun configurePlayer (seekToPositionMs : Long ) {
170168 // seek to the previous position if available
171169 if (seekToPositionMs != 0L ) {
172170 exoPlayer?.seekTo(seekToPositionMs)
@@ -201,10 +199,6 @@ open class OnlinePlayerService : AbstractPlayerService() {
201199
202200 // play new video on background
203201 setVideoId(nextVideo)
204- this .streams = null
205- this .sponsorBlockSegments = emptyList()
206-
207- Log .e(" play next" , " play next" )
208202
209203 scope.launch {
210204 startPlayback()
@@ -266,6 +260,13 @@ open class OnlinePlayerService : AbstractPlayerService() {
266260 }
267261 }
268262
263+ override fun setVideoId (videoId : String ) {
264+ super .setVideoId(videoId)
265+
266+ this .streams = null
267+ this .sponsorBlockSegments = emptyList()
268+ }
269+
269270 /* *
270271 * Sets the [MediaItem] with the [streams] into the [exoPlayer]
271272 */
0 commit comments