From 3226eef67ed88d034f376e3fd23ade960af14682 Mon Sep 17 00:00:00 2001 From: Samson50 Date: Wed, 8 May 2024 00:51:19 -0400 Subject: [PATCH] Playback continuation and AudioBook playlist/queue now working as desired after minor modifications to playbackmanager.js --- src/components/playback/playbackmanager.js | 13 ++++++++----- src/components/router/appRouter.js | 4 +--- src/controllers/books/booksmain.js | 1 - 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/components/playback/playbackmanager.js b/src/components/playback/playbackmanager.js index f6bd8c4d7c..0fedc0ef89 100644 --- a/src/components/playback/playbackmanager.js +++ b/src/components/playback/playbackmanager.js @@ -1969,6 +1969,9 @@ class PlaybackManager { if (promise) { return promise.then(function (result) { + if (firstItem.Type === 'AudioBook') { + options.startIndex = result.StartIndex; + } return result ? result.Items : items; }); } else { @@ -1982,9 +1985,7 @@ class PlaybackManager { // This is the exposed function called to manage item media playback self.play = function (options) { normalizePlayOptions(options); - console.debug('playing'); - // I think this class *is* the "localpalyer", others are plugins or chromecast if (self._currentPlayer) { if (options.enableRemotePlayers === false && !self._currentPlayer.isLocalPlayer) { return Promise.reject(); @@ -1995,13 +1996,11 @@ class PlaybackManager { } } - console.debug('using "localplayer" (*wink*)'); if (options.fullscreen) { loading.show(); } if (options.items) { - console.debug('playing from options.items'); return translateItemsForPlayback(options.items, options) .then((items) => getAdditionalParts(items)) .then(function (allItems) { @@ -2009,7 +2008,6 @@ class PlaybackManager { return playWithIntros(flattened, options); }); } else { - console.debug('calling getItemsForPlayback'); if (!options.serverId) { throw new Error('serverId required!'); } @@ -2238,6 +2236,10 @@ class PlaybackManager { } function playInternal(item, playOptions, onPlaybackStartedFn, prevSource) { + if (item.Type === 'AudioBookFile') { + playOptions.startPositionTicks = item.UserData.PlaybackPositionTicks; + } + if (item.IsPlaceHolder) { loading.hide(); showPlaybackInfoErrorMessage(self, 'PlaybackErrorPlaceHolder'); @@ -2499,6 +2501,7 @@ class PlaybackManager { } return Promise.all([promise, player.getDeviceProfile(item)]).then(function (responses) { + // TODO: Why does this skip the first entry? const deviceProfile = responses[1]; const apiClient = ServerConnections.getApiClient(item.ServerId); diff --git a/src/components/router/appRouter.js b/src/components/router/appRouter.js index 4e516a2269..31530edaec 100644 --- a/src/components/router/appRouter.js +++ b/src/components/router/appRouter.js @@ -693,9 +693,7 @@ class AppRouter { return url; } if (item.CollectionType == CollectionType.Books) { - let urlForList = '#/books.html?topParentId=' + item.Id; - - return urlForList; + return '#/books.html?parentId=' + id + '&serverId=' + serverId + '&topParentId=' + item.Id; } } diff --git a/src/controllers/books/booksmain.js b/src/controllers/books/booksmain.js index f5737b91f4..2cde5e1831 100644 --- a/src/controllers/books/booksmain.js +++ b/src/controllers/books/booksmain.js @@ -185,7 +185,6 @@ function getItems(instance, params, item, sortBy, startIndex, limit) { instance.queryRecursive = false; if (!item) { - // console.log("I dont think this is right"); instance.queryRecursive = true; return apiClient['getItems'](apiClient.getCurrentUserId(), modifyQueryWithFilters(instance, {