Skip to content

Commit

Permalink
add Play Next Episode Automatically user setting
Browse files Browse the repository at this point in the history
  • Loading branch information
cewert committed Jul 31, 2024
1 parent 8da8176 commit 9659186
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 18 deletions.
6 changes: 3 additions & 3 deletions components/ItemGrid/LoadVideoContentTask.bs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 8 additions & 6 deletions components/JFVideo.bs
Original file line number Diff line number Diff line change
Expand Up @@ -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

'
Expand Down
14 changes: 8 additions & 6 deletions components/video/VideoPlayerView.bs
Original file line number Diff line number Diff line change
Expand Up @@ -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

'
Expand Down
15 changes: 15 additions & 0 deletions locale/en_US/translations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1286,5 +1286,20 @@
<translation>Show already watched episodes in 'Next Up' sections.</translation>
<extracomment>User Setting - Setting description</extracomment>
</message>
<message>
<source>Play Next Episode Automatically</source>
<translation>Play Next Episode Automatically</translation>
<extracomment>User Setting - Setting title</extracomment>
</message>
<message>
<source>When finished playing a single episode, play the next one automatically.</source>
<translation>When finished playing a single episode, play the next one automatically.</translation>
<extracomment>User Setting - Setting description</extracomment>
</message>
<message>
<source>Use Web Client Setting</source>
<translation>Use Web Client Setting</translation>
<extracomment>User Setting - Setting option title</extracomment>
</message>
</context>
</TS>
21 changes: 21 additions & 0 deletions settings/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -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.",
Expand Down
6 changes: 3 additions & 3 deletions source/VideoPlayer.bs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 9659186

Please sign in to comment.