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

Fix stream selection remembering

This commit is contained in:
Shadowghost 2022-06-19 14:55:21 +02:00
parent c8590d37ed
commit 2b0091eca2
5 changed files with 37 additions and 26 deletions

View file

@ -2300,7 +2300,7 @@ class PlaybackManager {
}
}
function autoSetNextTracks(prevSource, mediaSource) {
function autoSetNextTracks(prevSource, mediaSource, audio, subtitle) {
try {
if (!prevSource) return;
@ -2319,8 +2319,11 @@ class PlaybackManager {
return;
}
rankStreamType(prevSource.DefaultAudioStreamIndex, prevSource, mediaSource, 'Audio');
rankStreamType(prevSource.DefaultSubtitleStreamIndex, prevSource, mediaSource, 'Subtitle');
if (audio)
rankStreamType(prevSource.DefaultAudioStreamIndex, prevSource, mediaSource, 'Audio');
if (subtitle)
rankStreamType(prevSource.DefaultSubtitleStreamIndex, prevSource, mediaSource, 'Subtitle');
} catch (e) {
console.error(`AutoSet - Caught unexpected error: ${e}`);
}
@ -2385,8 +2388,18 @@ class PlaybackManager {
playOptions.items = null;
return getPlaybackMediaSource(player, apiClient, deviceProfile, maxBitrate, item, startPosition, mediaSourceId, audioStreamIndex, subtitleStreamIndex).then(function (mediaSource) {
if (userSettings.enableSetUsingLastTracks())
autoSetNextTracks(prevSource, mediaSource);
const user = apiClient.getCurrentUser();
if (user.Configuration.RememberAudioSelections) {
if (user.Configuration.RememberSubtitleSelections)
autoSetNextTracks(prevSource, mediaSource, true, true);
else
autoSetNextTracks(prevSource, mediaSource, true, false);
} else {
if (user.Configuration.RememberSubtitleSelections)
autoSetNextTracks(prevSource, mediaSource, false, true);
else
autoSetNextTracks(prevSource, mediaSource, false, false);
}
const streamInfo = createStreamInfo(apiClient, item.MediaType, item, mediaSource, startPosition, player);

View file

@ -180,7 +180,8 @@ import template from './playbackSettings.template.html';
context.querySelector('.chkPreferFmp4HlsContainer').checked = userSettings.preferFmp4HlsContainer();
context.querySelector('.chkEnableCinemaMode').checked = userSettings.enableCinemaMode();
context.querySelector('.chkEnableNextVideoOverlay').checked = userSettings.enableNextVideoInfoOverlay();
context.querySelector('.chkSetUsingLastTracks').checked = userSettings.enableSetUsingLastTracks();
context.querySelector('.chkRememberAudioSelections').checked = user.Configuration.RememberAudioSelections || false;
context.querySelector('.chkRememberSubtitleSelections').checked = user.Configuration.RememberSubtitleSelections || false;
context.querySelector('.chkExternalVideoPlayer').checked = appSettings.enableSystemExternalPlayers();
setMaxBitrateIntoField(context.querySelector('.selectVideoInNetworkQuality'), true, 'Video');
@ -222,7 +223,8 @@ import template from './playbackSettings.template.html';
userSettingsInstance.enableCinemaMode(context.querySelector('.chkEnableCinemaMode').checked);
userSettingsInstance.enableNextVideoInfoOverlay(context.querySelector('.chkEnableNextVideoOverlay').checked);
userSettingsInstance.enableSetUsingLastTracks(context.querySelector('.chkSetUsingLastTracks').checked);
user.Configuration.RememberAudioSelections = context.querySelector('.chkRememberAudioSelections').checked;
user.Configuration.RememberSubtitleSelections = context.querySelector('.chkRememberSubtitleSelections').checked;
userSettingsInstance.chromecastVersion(context.querySelector('.selectChromecastVersion').value);
userSettingsInstance.skipForwardLength(context.querySelector('.selectSkipForwardLength').value);
userSettingsInstance.skipBackLength(context.querySelector('.selectSkipBackLength').value);

View file

@ -84,10 +84,18 @@
<div class="checkboxContainer checkboxContainer-withDescription">
<label>
<input type="checkbox" is="emby-checkbox" class="chkSetUsingLastTracks" />
<span>${SetUsingLastTracks}</span>
<input type="checkbox" is="emby-checkbox" class="chkRememberAudioSelections" />
<span>${RememberAudioSelections}</span>
</label>
<div class="fieldDescription checkboxFieldDescription">${SetUsingLastTracksHelp}</div>
<div class="fieldDescription checkboxFieldDescription">${RememberAudioSelectionsHelp}</div>
</div>
<div class="checkboxContainer checkboxContainer-withDescription">
<label>
<input type="checkbox" is="emby-checkbox" class="chkRememberSubtitleSelections" />
<span>${RememberSubtitleSelections}</span>
</label>
<div class="fieldDescription checkboxFieldDescription">${RememberSubtitleSelectionsHelp}</div>
</div>
<div class="checkboxContainer checkboxContainer-withDescription fldEnableNextVideoOverlay">

View file

@ -166,19 +166,6 @@ export class UserSettings {
return val !== 'false';
}
/**
* Get or set 'SetUsingLastTracks' state.
* @param {boolean|undefined} val - Flag to enable 'SetUsingLastTracks' or undefined.
* @return {boolean} 'SetUsingLastTracks' state.
*/
enableSetUsingLastTracks(val) {
if (val !== undefined) {
return this.set('enableSetUsingLastTracks', val.toString());
}
return this.get('enableSetUsingLastTracks', false) !== 'false';
}
/**
* Get or set 'Theme Songs' state.
* @param {boolean|undefined} val - Flag to enable 'Theme Songs' or undefined.
@ -570,7 +557,6 @@ export const allowedAudioChannels = currentSettings.allowedAudioChannels.bind(cu
export const preferFmp4HlsContainer = currentSettings.preferFmp4HlsContainer.bind(currentSettings);
export const enableCinemaMode = currentSettings.enableCinemaMode.bind(currentSettings);
export const enableNextVideoInfoOverlay = currentSettings.enableNextVideoInfoOverlay.bind(currentSettings);
export const enableSetUsingLastTracks = currentSettings.enableSetUsingLastTracks.bind(currentSettings);
export const enableThemeSongs = currentSettings.enableThemeSongs.bind(currentSettings);
export const enableThemeVideos = currentSettings.enableThemeVideos.bind(currentSettings);
export const enableFastFadein = currentSettings.enableFastFadein.bind(currentSettings);

View file

@ -1353,7 +1353,11 @@
"RefreshQueued": "Refresh queued.",
"ReleaseDate": "Release date",
"ReleaseGroup": "Release Group",
"RememberAudioSelections": "Set audio track based on previous item",
"RememberAudioSelectionsHelp": "Try to set the audio track to the closest match to the last video.",
"RememberMe": "Remember Me",
"RememberSubtitleSelections": "Set subtitle track based on previous item",
"RememberSubtitleSelectionsHelp": "Try to set the subtitle track to the closest match to the last video.",
"Remixer": "Remixer",
"RemoveFromCollection": "Remove from collection",
"RemoveFromPlaylist": "Remove from playlist",
@ -1401,8 +1405,6 @@
"Settings": "Settings",
"SettingsSaved": "Settings saved.",
"SettingsWarning": "Changing these values may cause instability or connectivity failures. If you experience any problems, we recommend changing them back to default.",
"SetUsingLastTracks": "Set Subtitle/Audio Tracks with Previous Item",
"SetUsingLastTracksHelp": "Try to set the Subtitle/Audio track to the closest match to the last video.",
"Share": "Share",
"ShowAdvancedSettings": "Show advanced settings",
"ShowIndicatorsFor": "Show indicators for:",