Skip to content

Commit 46e554a

Browse files
authored
Merge pull request libre-tube#7382 from Bnyro/master
fix: SponsorBlock segments of previous video not cleared when starting next
2 parents ea30d9d + fb05eb5 commit 46e554a

2 files changed

Lines changed: 11 additions & 10 deletions

File tree

app/src/main/java/com/github/libretube/services/AbstractPlayerService.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ abstract class AbstractPlayerService : MediaLibraryService(), MediaLibrarySessio
210210
* Update the [videoId] to the new videoId and change the playlist metadata
211211
* to reflect that videoId change
212212
*/
213-
protected fun setVideoId(videoId: String) {
213+
protected open fun setVideoId(videoId: String) {
214214
this.videoId = videoId
215215

216216
updatePlaylistMetadata {

app/src/main/java/com/github/libretube/services/OnlinePlayerService.kt

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import androidx.media3.common.MediaItem
99
import androidx.media3.common.MediaItem.SubtitleConfiguration
1010
import androidx.media3.common.MimeTypes
1111
import androidx.media3.common.Player
12-
import androidx.media3.common.util.Log
1312
import androidx.media3.datasource.DefaultDataSource
1413
import androidx.media3.exoplayer.hls.HlsMediaSource
1514
import 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

Comments
 (0)