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