fix(mpv): loading item immediately restarts the playback causing duplicate external subtitle entries

This commit is contained in:
Jarne Demeulemeester 2024-01-26 23:29:03 +01:00
parent c7849a70c3
commit 07c58accf0
No known key found for this signature in database
GPG key ID: 1E5C6AFBD622E9F5

View file

@ -869,8 +869,11 @@ class MPVPlayer(
)
}
currentIndex = index
// Only set the playlist index when the index is not the currently playing item. Otherwise playback will be restarted.
// This is a problem on initial load when the first item is still loading causing duplicate external subtitle entries.
if (MPVLib.getPropertyInt("playlist-current-pos") != index) {
MPVLib.command(arrayOf("playlist-play-index", "$index"))
MPVLib.setPropertyBoolean("pause", true)
}
listeners.sendEvent(Player.EVENT_TIMELINE_CHANGED) { listener ->
listener.onTimelineChanged(timeline, Player.TIMELINE_CHANGE_REASON_PLAYLIST_CHANGED)
}