-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Implement playback inactivity timeout #6686
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
7c2b62e
2092bf4
11f1030
7b887ec
da0c03d
73aaf77
d491610
c85996b
51b2214
f37e54b
e64c0e6
49f5c74
21399d5
bc1efe3
ca508a3
003e57a
c702633
eda62d5
433717f
1e8edd5
5c83093
52e4883
f25665d
efd70d0
a8dde66
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -140,6 +140,29 @@ function setMaxBitrateFromField(select, isInNetwork, mediatype) { | |||||||||||
} | ||||||||||||
} | ||||||||||||
|
||||||||||||
function showHideStillWatchingOptions(context) { | ||||||||||||
const stillWatchingEnabled = context.querySelector('.chkStillWatching').checked; | ||||||||||||
const optionsContainer = context.querySelector('.stillWatchingOptions'); | ||||||||||||
|
||||||||||||
if (stillWatchingEnabled) { | ||||||||||||
optionsContainer.classList.remove('hide'); | ||||||||||||
} else { | ||||||||||||
optionsContainer.classList.add('hide'); | ||||||||||||
} | ||||||||||||
} | ||||||||||||
|
||||||||||||
function initStillWatchingControls(context) { | ||||||||||||
const modeSelect = context.querySelector('#selectStillWatchingMode'); | ||||||||||||
const episodeContainer = context.querySelector('.episodeContainer'); | ||||||||||||
const timeContainer = context.querySelector('.timeContainer'); | ||||||||||||
|
||||||||||||
modeSelect.addEventListener('change', () => { | ||||||||||||
const isTimeMode = modeSelect.value === 'time'; | ||||||||||||
episodeContainer.classList.toggle('hide', isTimeMode); | ||||||||||||
timeContainer.classList.toggle('hide', !isTimeMode); | ||||||||||||
}); | ||||||||||||
} | ||||||||||||
|
||||||||||||
function showHideQualityFields(context, user, apiClient) { | ||||||||||||
if (user.Policy.EnableVideoPlaybackTranscoding) { | ||||||||||||
context.querySelector('.videoQualitySection').classList.remove('hide'); | ||||||||||||
|
@@ -185,6 +208,7 @@ function loadForm(context, user, userSettings, systemInfo, apiClient) { | |||||||||||
const userId = user.Id; | ||||||||||||
|
||||||||||||
showHideQualityFields(context, user, apiClient); | ||||||||||||
showHideStillWatchingOptions(context); | ||||||||||||
|
||||||||||||
if (browser.safari) { | ||||||||||||
context.querySelector('.fldEnableHi10p').classList.remove('hide'); | ||||||||||||
|
@@ -225,6 +249,12 @@ function loadForm(context, user, userSettings, systemInfo, apiClient) { | |||||||||||
context.querySelector('.chkEnableHi10p').checked = appSettings.enableHi10p(); | ||||||||||||
context.querySelector('.chkEnableCinemaMode').checked = userSettings.enableCinemaMode(); | ||||||||||||
context.querySelector('#selectAudioNormalization').value = userSettings.selectAudioNormalization(); | ||||||||||||
|
||||||||||||
context.querySelector('.chkStillWatching').checked = userSettings.enableStillWatching(); | ||||||||||||
context.querySelector('#stillWatchingEpisodeCount').value = userSettings.askAfterNumEpisodes() || 1; | ||||||||||||
displayStillWatchingMode(context, userSettings); | ||||||||||||
showHideStillWatchingOptions(context); | ||||||||||||
|
||||||||||||
context.querySelector('.chkEnableNextVideoOverlay').checked = userSettings.enableNextVideoInfoOverlay(); | ||||||||||||
context.querySelector('.chkRememberAudioSelections').checked = user.Configuration.RememberAudioSelections || false; | ||||||||||||
context.querySelector('.chkRememberSubtitleSelections').checked = user.Configuration.RememberSubtitleSelections || false; | ||||||||||||
|
@@ -265,6 +295,7 @@ function loadForm(context, user, userSettings, systemInfo, apiClient) { | |||||||||||
populateMediaSegments(mediaSegmentContainer, userSettings); | ||||||||||||
|
||||||||||||
loading.hide(); | ||||||||||||
initStillWatchingControls(context); | ||||||||||||
Comment on lines
297
to
+298
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's hide the loading indicator at the end.
Suggested change
|
||||||||||||
} | ||||||||||||
|
||||||||||||
function saveUser(context, user, userSettingsInstance, apiClient) { | ||||||||||||
|
@@ -292,6 +323,16 @@ function saveUser(context, user, userSettingsInstance, apiClient) { | |||||||||||
user.Configuration.AudioLanguagePreference = context.querySelector('#selectAudioLanguage').value; | ||||||||||||
user.Configuration.PlayDefaultAudioTrack = context.querySelector('.chkPlayDefaultAudioTrack').checked; | ||||||||||||
user.Configuration.EnableNextEpisodeAutoPlay = context.querySelector('.chkEpisodeAutoPlay').checked; | ||||||||||||
|
||||||||||||
userSettingsInstance.enableStillWatching(context.querySelector('.chkStillWatching').checked); | ||||||||||||
const mode = context.querySelector('#selectStillWatchingMode').value; | ||||||||||||
|
||||||||||||
userSettingsInstance.timeBasedStillWatching(mode === 'time'); | ||||||||||||
if (mode === 'time') { | ||||||||||||
userSettingsInstance.stillWatchingTimeout(context.querySelector('#stillWatchingTime').value); | ||||||||||||
} else { | ||||||||||||
userSettingsInstance.askAfterNumEpisodes(context.querySelector('#stillWatchingEpisodeCount').value); | ||||||||||||
} | ||||||||||||
userSettingsInstance.preferFmp4HlsContainer(context.querySelector('.chkPreferFmp4HlsContainer').checked); | ||||||||||||
userSettingsInstance.enableCinemaMode(context.querySelector('.chkEnableCinemaMode').checked); | ||||||||||||
userSettingsInstance.selectAudioNormalization(context.querySelector('#selectAudioNormalization').value); | ||||||||||||
|
@@ -347,9 +388,13 @@ function onSubmit(e) { | |||||||||||
|
||||||||||||
function embed(options, self) { | ||||||||||||
options.element.innerHTML = globalize.translateHtml(template, 'core'); | ||||||||||||
|
||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please revert unnecessary changes (blank line removal). |
||||||||||||
options.element.querySelector('form').addEventListener('submit', onSubmit.bind(self)); | ||||||||||||
|
||||||||||||
const stillWatchingCheckbox = options.element.querySelector('.chkStillWatching'); | ||||||||||||
stillWatchingCheckbox.addEventListener('change', () => { | ||||||||||||
showHideStillWatchingOptions(options.element); | ||||||||||||
}); | ||||||||||||
|
||||||||||||
if (options.enableSaveButton) { | ||||||||||||
options.element.querySelector('.btnSave').classList.remove('hide'); | ||||||||||||
} | ||||||||||||
|
@@ -361,6 +406,35 @@ function embed(options, self) { | |||||||||||
} | ||||||||||||
} | ||||||||||||
|
||||||||||||
function displayStillWatchingMode(context, userSettings) { | ||||||||||||
// Determine saved mode | ||||||||||||
const isTimeMode = userSettings.timeBasedStillWatching?.() === true; | ||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why do you need optional chain for |
||||||||||||
const mode = isTimeMode ? 'time' : 'episodes'; | ||||||||||||
|
||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It would be better to make |
||||||||||||
// Set mode select dropdown | ||||||||||||
const modeSelect = context.querySelector('#selectStillWatchingMode'); | ||||||||||||
modeSelect.value = mode; | ||||||||||||
|
||||||||||||
// Containers | ||||||||||||
const episodeContainer = context.querySelector('.episodeContainer'); | ||||||||||||
const timeContainer = context.querySelector('.timeContainer'); | ||||||||||||
|
||||||||||||
// Toggle visibility | ||||||||||||
episodeContainer.classList.toggle('hide', isTimeMode); | ||||||||||||
timeContainer.classList.toggle('hide', !isTimeMode); | ||||||||||||
|
||||||||||||
// Inputs | ||||||||||||
const timeInput = context.querySelector('#stillWatchingTime'); | ||||||||||||
const episodeInput = context.querySelector('#stillWatchingEpisodeCount'); | ||||||||||||
|
||||||||||||
// Populate only the relevant field | ||||||||||||
if (isTimeMode) { | ||||||||||||
timeInput.value = userSettings.stillWatchingTimeout() || 300; | ||||||||||||
} else { | ||||||||||||
episodeInput.value = userSettings.askAfterNumEpisodes() || 5; | ||||||||||||
} | ||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You already have default values.
Normally we put the default value in the setting getter. |
||||||||||||
} | ||||||||||||
|
||||||||||||
class PlaybackSettings { | ||||||||||||
constructor(options) { | ||||||||||||
this.options = options; | ||||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.