From fa4f669e7d809e3546d86b4d2a7f722f0cd14896 Mon Sep 17 00:00:00 2001 From: Courville Software Date: Sun, 29 Dec 2024 18:26:59 +0100 Subject: [PATCH] VideoDbInfo: sets last audioTrack and subtitleTrack correctly from playParams if not played before Solves issue of not being able to resume on foreign first audioTrack that happens in the video attached to issue #1355 See https://github.com/nova-video-player/aos-AVP/issues/1355 --- .../mediacenter/utils/videodb/VideoDbInfo.java | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/com/archos/mediacenter/utils/videodb/VideoDbInfo.java b/src/com/archos/mediacenter/utils/videodb/VideoDbInfo.java index d61db8c6..c11e3ede 100644 --- a/src/com/archos/mediacenter/utils/videodb/VideoDbInfo.java +++ b/src/com/archos/mediacenter/utils/videodb/VideoDbInfo.java @@ -31,8 +31,13 @@ import com.archos.mediascraper.ScrapeStatus; import com.archos.mediascraper.ShowTags; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + public class VideoDbInfo implements Parcelable { + private static final Logger log = LoggerFactory.getLogger(VideoDbInfo.class); + public VideoDbInfo() {} public VideoDbInfo(String path) { @@ -197,15 +202,19 @@ public static VideoDbInfo fromCursor(Cursor c, boolean shouldMoveToNext) { result.duration = c.getInt(IDX_DURATION); result.resume = c.getInt(IDX_BOOKMARK); result.bookmark = c.getInt(IDX_ARCHOS_BOOKMARK); + result.lastTimePlayed = c.getLong(IDX_LAST_TIME_PLAYED); int playerParams = c.getInt(IDX_PLAYER_PARAMS); - // ensure that audioTrack is -1 if not played before - if (playerParams != 0) result.audioTrack = VideoStore.paramsToAudioTrack(playerParams); + // ensure that audioTrack is -1 if not played before (playParams is 0 if not played before but 0 could be a valid audioTrack if played before) + if (result.lastTimePlayed > 0) result.audioTrack = VideoStore.paramsToAudioTrack(playerParams); else result.audioTrack = -1; - result.subtitleTrack = VideoStore.paramsToSubtitleTrack(playerParams); + log.debug("fromCursor: lastTimePlayed={}, playerParams={}, paramsToAudioTrack={}, audioTrack={}", result.lastTimePlayed, playerParams, VideoStore.paramsToAudioTrack(playerParams), result.audioTrack); + // ensure that audioTrack is -1 if not played before (playParams is 0 if not played before but 0 could be a valid audioTrack if played before) + if (result.lastTimePlayed > 0) result.subtitleTrack = VideoStore.paramsToSubtitleTrack(playerParams); + else result.subtitleTrack = -1; + log.debug("fromCursor: result.lastTimePlayed={}, playerParams={}, paramsToSubtitleTrack={}, subtitleTrack={}", result.lastTimePlayed, playerParams, VideoStore.paramsToSubtitleTrack(playerParams), result.subtitleTrack); result.subtitleDelay = c.getInt(IDX_SUBTITLE_DELAY); result.subtitleRatio = c.getInt(IDX_SUBTITLE_RATIO); result.nbSubtitles = c.getInt(IDX_NB_SUBTITLES); - result.lastTimePlayed = c.getLong(IDX_LAST_TIME_PLAYED); result.traktSeen = c.getInt(IDX_TRAKT_SEEN); result.traktLibrary = c.getInt(IDX_TRAKT_LIBRARY); result.traktResume = c.getInt(IDX_TRAKT_RESUME);