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:
parent
0473c8a18c
commit
6c4a3ec6f1
2 changed files with 30 additions and 6 deletions
|
@ -57,6 +57,7 @@
|
|||
- [Meet Pandya](https://github.com/meet-k-pandya)
|
||||
- [Peter Spenler](https://github.com/peterspenler)
|
||||
- [Vankerkom](https://github.com/vankerkom)
|
||||
- [Rob Farraher](https://github.com/farraherbg)
|
||||
|
||||
# Emby Contributors
|
||||
|
||||
|
|
|
@ -1887,9 +1887,12 @@ class PlaybackManager {
|
|||
}
|
||||
|
||||
if (options.items) {
|
||||
return translateItemsForPlayback(options.items, options).then(function (items) {
|
||||
return playWithIntros(items, options);
|
||||
});
|
||||
return translateItemsForPlayback(options.items, options)
|
||||
.then((items) => getAdditionalParts(items))
|
||||
.then(function (allItems) {
|
||||
const flattened = allItems.flatMap(i => i);
|
||||
return playWithIntros(flattened, options);
|
||||
});
|
||||
} else {
|
||||
if (!options.serverId) {
|
||||
throw new Error('serverId required!');
|
||||
|
@ -1898,9 +1901,12 @@ class PlaybackManager {
|
|||
return getItemsForPlayback(options.serverId, {
|
||||
Ids: options.ids.join(',')
|
||||
}).then(function (result) {
|
||||
return translateItemsForPlayback(result.Items, options).then(function (items) {
|
||||
return playWithIntros(items, options);
|
||||
});
|
||||
return translateItemsForPlayback(result.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);
|
||||
}
|
||||
|
||||
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) {
|
||||
let playStartIndex = options.startIndex || 0;
|
||||
let firstItem = items[playStartIndex];
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue