From 96591865e4e6d9a6a23622480e5bff2a4b398210 Mon Sep 17 00:00:00 2001 From: Charles Ewert Date: Tue, 30 Jul 2024 21:27:46 -0400 Subject: [PATCH] add `Play Next Episode Automatically` user setting --- components/ItemGrid/LoadVideoContentTask.bs | 6 +++--- components/JFVideo.bs | 14 ++++++++------ components/video/VideoPlayerView.bs | 14 ++++++++------ locale/en_US/translations.ts | 15 +++++++++++++++ settings/settings.json | 21 +++++++++++++++++++++ source/VideoPlayer.bs | 6 +++--- 6 files changed, 58 insertions(+), 18 deletions(-) diff --git a/components/ItemGrid/LoadVideoContentTask.bs b/components/ItemGrid/LoadVideoContentTask.bs index 83cb4b0da..ff28efe34 100644 --- a/components/ItemGrid/LoadVideoContentTask.bs +++ b/components/ItemGrid/LoadVideoContentTask.bs @@ -119,9 +119,9 @@ sub LoadItems_AddVideoContent(video as object, mediaSourceId as dynamic, audio_s video.logoImage = api.items.GetImageURL(logoLookupID, "logo", 0, { "maxHeight": 65, "maxWidth": 300, "quality": "90" }) end if - user = AboutMe() - if user.Configuration.EnableNextEpisodeAutoPlay - if LCase(m.top.itemType) = "episode" + if LCase(m.top.itemType) = "episode" + userSession = m.global.session.user + if userSession.settings["playback.playnextepisode"] = "enabled" or userSession.settings["playback.playnextepisode"] = "webclient" and userSession.Configuration.EnableNextEpisodeAutoPlay addNextEpisodesToQueue(video.showID) end if end if diff --git a/components/JFVideo.bs b/components/JFVideo.bs index f4dfb74e8..5be3d8537 100644 --- a/components/JFVideo.bs +++ b/components/JFVideo.bs @@ -92,12 +92,14 @@ end sub sub showNextEpisodeButton() if m.top.content.contenttype <> 4 then return ' only display when content is type "Episode" if m.nextupbuttonseconds = 0 then return ' is the button disabled? - - if m.nextEpisodeButton.opacity = 0 and m.global.session.user.configuration.EnableNextEpisodeAutoPlay - m.nextEpisodeButton.visible = true - m.showNextEpisodeButtonAnimation.control = "start" - m.nextEpisodeButton.setFocus(true) - end if + if m.nextEpisodeButton.opacity <> 0 then return + userSession = m.global.session.user + if userSession.settings["playback.playnextepisode"] = "disabled" then return + if userSession.settings["playback.playnextepisode"] = "webclient" and not userSession.Configuration.EnableNextEpisodeAutoPlay then return + + m.nextEpisodeButton.visible = true + m.showNextEpisodeButtonAnimation.control = "start" + m.nextEpisodeButton.setFocus(true) end sub ' diff --git a/components/video/VideoPlayerView.bs b/components/video/VideoPlayerView.bs index 56f230ee8..be0d32be2 100644 --- a/components/video/VideoPlayerView.bs +++ b/components/video/VideoPlayerView.bs @@ -517,12 +517,14 @@ sub showNextEpisodeButton() if m.osd.visible then return if m.top.content.contenttype <> 4 then return ' only display when content is type "Episode" if m.nextupbuttonseconds = 0 then return ' is the button disabled? - - if m.nextEpisodeButton.opacity = 0 and m.global.session.user.configuration.EnableNextEpisodeAutoPlay - m.nextEpisodeButton.visible = true - m.showNextEpisodeButtonAnimation.control = "start" - m.nextEpisodeButton.setFocus(true) - end if + if m.nextEpisodeButton.opacity <> 0 then return + userSession = m.global.session.user + if userSession.settings["playback.playnextepisode"] = "disabled" then return + if userSession.settings["playback.playnextepisode"] = "webclient" and not userSession.Configuration.EnableNextEpisodeAutoPlay then return + + m.nextEpisodeButton.visible = true + m.showNextEpisodeButtonAnimation.control = "start" + m.nextEpisodeButton.setFocus(true) end sub ' diff --git a/locale/en_US/translations.ts b/locale/en_US/translations.ts index fe5666d25..6d33ead83 100644 --- a/locale/en_US/translations.ts +++ b/locale/en_US/translations.ts @@ -1286,5 +1286,20 @@ Show already watched episodes in 'Next Up' sections. User Setting - Setting description + + Play Next Episode Automatically + Play Next Episode Automatically + User Setting - Setting title + + + When finished playing a single episode, play the next one automatically. + When finished playing a single episode, play the next one automatically. + User Setting - Setting description + + + Use Web Client Setting + Use Web Client Setting + User Setting - Setting option title + diff --git a/settings/settings.json b/settings/settings.json index 6f5e15c00..48a7da067 100644 --- a/settings/settings.json +++ b/settings/settings.json @@ -174,6 +174,27 @@ "type": "integer", "default": "30" }, + { + "title": "Play Next Episode Automatically", + "description": "When finished playing a single episode, play the next one automatically.", + "settingName": "playback.playnextepisode", + "type": "radio", + "default": "webclient", + "options": [ + { + "title": "Use Web Client Setting", + "id": "webclient" + }, + { + "title": "Enabled", + "id": "enabled" + }, + { + "title": "Disabled", + "id": "disabled" + } + ] + }, { "title": "Preferred Audio Codec", "description": "Use the selected audio codec for transcodes. If the device or stream does not support it, a fallback codec will be used.", diff --git a/source/VideoPlayer.bs b/source/VideoPlayer.bs index 1c4f7e758..d034b78ef 100644 --- a/source/VideoPlayer.bs +++ b/source/VideoPlayer.bs @@ -435,11 +435,11 @@ function getAudioInfo(meta as object) as object end function sub autoPlayNextEpisode(videoID as string, showID as string) - ' use web client setting - if m.global.session.user.configuration.EnableNextEpisodeAutoPlay + userSession = m.global.session.user + if userSession.settings["playback.playnextepisode"] = "enabled" or userSession.settings["playback.playnextepisode"] = "webclient" and userSession.Configuration.EnableNextEpisodeAutoPlay ' query API for next episode ID url = Substitute("Shows/{0}/Episodes", showID) - urlParams = { "UserId": m.global.session.user.id } + urlParams = { "UserId": userSession.id } urlParams.Append({ "StartItemId": videoID }) urlParams.Append({ "Limit": 2 }) resp = APIRequest(url, urlParams)