mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
Fix incorrect audio & subtitle index on next track
This commit is contained in:
parent
f6d62f0dec
commit
4c31742cc5
1 changed files with 37 additions and 20 deletions
|
@ -2407,20 +2407,20 @@ class PlaybackManager {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function rankStreamType(prevIndex, prevSource, mediaSource, streamType, isSecondarySubtitle) {
|
function rankStreamType(prevIndex, prevSource, mediaStreams, trackOptions, streamType, isSecondarySubtitle) {
|
||||||
if (prevIndex == -1) {
|
if (prevIndex == -1) {
|
||||||
console.debug(`AutoSet ${streamType} - No Stream Set`);
|
console.debug(`AutoSet ${streamType} - No Stream Set`);
|
||||||
if (streamType == 'Subtitle') {
|
if (streamType == 'Subtitle') {
|
||||||
if (isSecondarySubtitle) {
|
if (isSecondarySubtitle) {
|
||||||
mediaSource.DefaultSecondarySubtitleStreamIndex = -1;
|
trackOptions.DefaultSecondarySubtitleStreamIndex = -1;
|
||||||
} else {
|
} else {
|
||||||
mediaSource.DefaultSubtitleStreamIndex = -1;
|
trackOptions.DefaultSubtitleStreamIndex = -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!prevSource.MediaStreams || !mediaSource.MediaStreams) {
|
if (!prevSource.MediaStreams || !mediaStreams) {
|
||||||
console.debug(`AutoSet ${streamType} - No MediaStreams`);
|
console.debug(`AutoSet ${streamType} - No MediaStreams`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -2446,7 +2446,7 @@ class PlaybackManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
let newRelIndex = 0;
|
let newRelIndex = 0;
|
||||||
for (const stream of mediaSource.MediaStreams) {
|
for (const stream of mediaStreams) {
|
||||||
if (stream.Type != streamType) continue;
|
if (stream.Type != streamType) continue;
|
||||||
|
|
||||||
let score = 0;
|
let score = 0;
|
||||||
|
@ -2469,38 +2469,38 @@ class PlaybackManager {
|
||||||
console.debug(`AutoSet ${streamType} - Using ${bestStreamIndex} score ${bestStreamScore}.`);
|
console.debug(`AutoSet ${streamType} - Using ${bestStreamIndex} score ${bestStreamScore}.`);
|
||||||
if (streamType == 'Subtitle') {
|
if (streamType == 'Subtitle') {
|
||||||
if (isSecondarySubtitle) {
|
if (isSecondarySubtitle) {
|
||||||
mediaSource.DefaultSecondarySubtitleStreamIndex = bestStreamIndex;
|
trackOptions.DefaultSecondarySubtitleStreamIndex = bestStreamIndex;
|
||||||
} else {
|
} else {
|
||||||
mediaSource.DefaultSubtitleStreamIndex = bestStreamIndex;
|
trackOptions.DefaultSubtitleStreamIndex = bestStreamIndex;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (streamType == 'Audio') {
|
if (streamType == 'Audio') {
|
||||||
mediaSource.DefaultAudioStreamIndex = bestStreamIndex;
|
trackOptions.DefaultAudioStreamIndex = bestStreamIndex;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
console.debug(`AutoSet ${streamType} - Threshold not met. Using default.`);
|
console.debug(`AutoSet ${streamType} - Threshold not met. Using default.`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function autoSetNextTracks(prevSource, mediaSource, audio, subtitle) {
|
function autoSetNextTracks(prevSource, mediaStreams, trackOptions, audio, subtitle) {
|
||||||
try {
|
try {
|
||||||
if (!prevSource) return;
|
if (!prevSource) return;
|
||||||
|
|
||||||
if (!mediaSource) {
|
if (!mediaStreams) {
|
||||||
console.warn('AutoSet - No mediaSource');
|
console.warn('AutoSet - No mediaStreams');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (audio && typeof prevSource.DefaultAudioStreamIndex == 'number') {
|
if (audio && typeof prevSource.DefaultAudioStreamIndex == 'number') {
|
||||||
rankStreamType(prevSource.DefaultAudioStreamIndex, prevSource, mediaSource, 'Audio');
|
rankStreamType(prevSource.DefaultAudioStreamIndex, prevSource, mediaStreams, trackOptions, 'Audio');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (subtitle && typeof prevSource.DefaultSubtitleStreamIndex == 'number') {
|
if (subtitle && typeof prevSource.DefaultSubtitleStreamIndex == 'number') {
|
||||||
rankStreamType(prevSource.DefaultSubtitleStreamIndex, prevSource, mediaSource, 'Subtitle');
|
rankStreamType(prevSource.DefaultSubtitleStreamIndex, prevSource, mediaStreams, trackOptions, 'Subtitle');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (subtitle && typeof prevSource.DefaultSecondarySubtitleStreamIndex == 'number') {
|
if (subtitle && typeof prevSource.DefaultSecondarySubtitleStreamIndex == 'number') {
|
||||||
rankStreamType(prevSource.DefaultSecondarySubtitleStreamIndex, prevSource, mediaSource, 'Subtitle', true);
|
rankStreamType(prevSource.DefaultSecondarySubtitleStreamIndex, prevSource, mediaStreams, trackOptions, 'Subtitle', true);
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error(`AutoSet - Caught unexpected error: ${e}`);
|
console.error(`AutoSet - Caught unexpected error: ${e}`);
|
||||||
|
@ -2572,12 +2572,18 @@ class PlaybackManager {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
return Promise.all([promise, player.getDeviceProfile(item)]).then(function (responses) {
|
|
||||||
const deviceProfile = responses[1];
|
|
||||||
|
|
||||||
const apiClient = ServerConnections.getApiClient(item.ServerId);
|
const apiClient = ServerConnections.getApiClient(item.ServerId);
|
||||||
|
const mediaSourceId = playOptions.mediaSourceId || item.Id;
|
||||||
|
const getMediaStreams = apiClient.getItem(apiClient.getCurrentUserId(), mediaSourceId)
|
||||||
|
.then(fullItem => {
|
||||||
|
return fullItem.MediaStreams;
|
||||||
|
});
|
||||||
|
|
||||||
|
return Promise.all([promise, player.getDeviceProfile(item), apiClient.getCurrentUser(), getMediaStreams]).then(function (responses) {
|
||||||
|
const deviceProfile = responses[1];
|
||||||
|
const user = responses[2];
|
||||||
|
const mediaStreams = responses[3];
|
||||||
|
|
||||||
const mediaSourceId = playOptions.mediaSourceId;
|
|
||||||
const audioStreamIndex = playOptions.audioStreamIndex;
|
const audioStreamIndex = playOptions.audioStreamIndex;
|
||||||
const subtitleStreamIndex = playOptions.subtitleStreamIndex;
|
const subtitleStreamIndex = playOptions.subtitleStreamIndex;
|
||||||
const options = {
|
const options = {
|
||||||
|
@ -2600,9 +2606,20 @@ class PlaybackManager {
|
||||||
// this reference was only needed by sendPlaybackListToPlayer
|
// this reference was only needed by sendPlaybackListToPlayer
|
||||||
playOptions.items = null;
|
playOptions.items = null;
|
||||||
|
|
||||||
|
const trackOptions = {};
|
||||||
|
|
||||||
|
autoSetNextTracks(prevSource, mediaStreams, trackOptions, user.Configuration.RememberAudioSelections, user.Configuration.RememberSubtitleSelections);
|
||||||
|
if (trackOptions.DefaultAudioStreamIndex != null) {
|
||||||
|
options.audioStreamIndex = trackOptions.DefaultAudioStreamIndex;
|
||||||
|
}
|
||||||
|
if (trackOptions.DefaultSubtitleStreamIndex != null) {
|
||||||
|
options.subtitleStreamIndex = trackOptions.DefaultSubtitleStreamIndex;
|
||||||
|
}
|
||||||
|
|
||||||
return getPlaybackMediaSource(player, apiClient, deviceProfile, item, mediaSourceId, options).then(async (mediaSource) => {
|
return getPlaybackMediaSource(player, apiClient, deviceProfile, item, mediaSourceId, options).then(async (mediaSource) => {
|
||||||
const user = await apiClient.getCurrentUser();
|
if (trackOptions.DefaultSecondarySubtitleStreamIndex != null) {
|
||||||
autoSetNextTracks(prevSource, mediaSource, user.Configuration.RememberAudioSelections, user.Configuration.RememberSubtitleSelections);
|
mediaSource.DefaultSecondarySubtitleStreamIndex = trackOptions.DefaultSecondarySubtitleStreamIndex;
|
||||||
|
}
|
||||||
|
|
||||||
if (mediaSource.DefaultSubtitleStreamIndex == null || mediaSource.DefaultSubtitleStreamIndex < 0) {
|
if (mediaSource.DefaultSubtitleStreamIndex == null || mediaSource.DefaultSubtitleStreamIndex < 0) {
|
||||||
mediaSource.DefaultSubtitleStreamIndex = mediaSource.DefaultSecondarySubtitleStreamIndex;
|
mediaSource.DefaultSubtitleStreamIndex = mediaSource.DefaultSecondarySubtitleStreamIndex;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue