Fix trailer playback when no local trailers are available

This commit is contained in:
Dmitry Lyzo 2022-01-14 23:33:20 +03:00
parent cc6611a98a
commit e455ecbb75

View File

@ -3499,7 +3499,7 @@ class PlaybackManager {
this.seek(ticks, player);
}
playTrailers(item) {
async playTrailers(item) {
const player = this._currentPlayer;
if (player && player.playTrailers) {
@ -3508,33 +3508,31 @@ class PlaybackManager {
const apiClient = ServerConnections.getApiClient(item.ServerId);
const instance = this;
let items;
if (item.LocalTrailerCount) {
return apiClient.getLocalTrailers(apiClient.getCurrentUserId(), item.Id).then(function (result) {
return instance.play({
items: result
});
});
} else {
const remoteTrailers = item.RemoteTrailers || [];
items = await apiClient.getLocalTrailers(apiClient.getCurrentUserId(), item.Id);
}
if (!remoteTrailers.length) {
return Promise.reject();
}
return this.play({
items: remoteTrailers.map(function (t) {
return {
Name: t.Name || (item.Name + ' Trailer'),
Url: t.Url,
MediaType: 'Video',
Type: 'Trailer',
ServerId: apiClient.serverId()
};
})
if (!items || !items.length) {
items = (item.RemoteTrailers || []).map((t) => {
return {
Name: t.Name || (item.Name + ' Trailer'),
Url: t.Url,
MediaType: 'Video',
Type: 'Trailer',
ServerId: apiClient.serverId()
};
});
}
if (items.length) {
return this.play({
items
});
}
return Promise.reject();
}
getSubtitleUrl(textStream, serverId) {