1
0
Fork 0
mirror of https://github.com/jellyfin/jellyfin-web synced 2025-03-30 19:56:21 +00:00

Add getAdditionalParts method to playbackmanager

Adds support for seamless playback of multipart Movies.
When a movie with an additional part is played,
enqueue the additional parts in the playlist.
This commit is contained in:
Rob Farraher 2022-12-14 10:51:55 -05:00 committed by Bill Thornton
parent 0473c8a18c
commit 6c4a3ec6f1
2 changed files with 30 additions and 6 deletions

View file

@ -57,6 +57,7 @@
- [Meet Pandya](https://github.com/meet-k-pandya) - [Meet Pandya](https://github.com/meet-k-pandya)
- [Peter Spenler](https://github.com/peterspenler) - [Peter Spenler](https://github.com/peterspenler)
- [Vankerkom](https://github.com/vankerkom) - [Vankerkom](https://github.com/vankerkom)
- [Rob Farraher](https://github.com/farraherbg)
# Emby Contributors # Emby Contributors

View file

@ -1887,9 +1887,12 @@ class PlaybackManager {
} }
if (options.items) { if (options.items) {
return translateItemsForPlayback(options.items, options).then(function (items) { return translateItemsForPlayback(options.items, options)
return playWithIntros(items, options); .then((items) => getAdditionalParts(items))
}); .then(function (allItems) {
const flattened = allItems.flatMap(i => i);
return playWithIntros(flattened, options);
});
} else { } else {
if (!options.serverId) { if (!options.serverId) {
throw new Error('serverId required!'); throw new Error('serverId required!');
@ -1898,9 +1901,12 @@ class PlaybackManager {
return getItemsForPlayback(options.serverId, { return getItemsForPlayback(options.serverId, {
Ids: options.ids.join(',') Ids: options.ids.join(',')
}).then(function (result) { }).then(function (result) {
return translateItemsForPlayback(result.Items, options).then(function (items) { return translateItemsForPlayback(result.Items, options)
return playWithIntros(items, options); .then((items) => getAdditionalParts(items))
}); .then(function (allItems) {
const flattened = allItems.flatMap(i => i);
return playWithIntros(flattened, options);
});
}); });
} }
}; };
@ -2039,6 +2045,23 @@ class PlaybackManager {
return player.play(options); return player.play(options);
} }
const getAdditionalParts = async (items) => {
const getOneAdditionalPart = async function (item) {
let retVal = [item];
if (item.Type === 'Movie') {
const client = ServerConnections.getApiClient(item.ServerId);
const user = await client.getCurrentUser();
const additionalParts = await client.getAdditionalVideoParts(user.Id, item.Id);
if (additionalParts.Items.length) {
retVal = [item, ...additionalParts.Items];
}
}
return retVal;
};
return Promise.all(items.flatMap(async (item) => getOneAdditionalPart(item)));
};
function playWithIntros(items, options) { function playWithIntros(items, options) {
let playStartIndex = options.startIndex || 0; let playStartIndex = options.startIndex || 0;
let firstItem = items[playStartIndex]; let firstItem = items[playStartIndex];