Check web client setting before autoplay

This commit is contained in:
cewert 2020-12-11 02:38:19 -05:00
parent f2a42c60e1
commit 47155a6b38
2 changed files with 27 additions and 22 deletions

View File

@ -404,7 +404,7 @@ sub Main()
RemoveCurrentGroup()
else
MarkItemWatched(video.id)
playNextEpisode(video.id, video.showID)
autoPlayNextEpisode(video.id, video.showID)
end if
end if
else if isNodeEvent(msg, "fire")
@ -416,7 +416,7 @@ sub Main()
if node.showID = invalid then
RemoveCurrentGroup()
else
playNextEpisode(node.id, node.showID)
autoPlayNextEpisode(node.id, node.showID)
end if
else if node.state = "playing" or node.state = "paused" then
ReportPlayback(group, "update")

View File

@ -337,27 +337,32 @@ function displaySubtitlesByUserConfig(subtitleTrack, audioTrack)
end if
end function
function playNextEpisode(videoID as string, showID as string)
' query API for next episode ID
url = Substitute("Shows/{0}/Episodes", showID)
urlParams = { "UserId": get_setting("active_user")}
urlParams.Append({ "StartItemId": videoID })
urlParams.Append({ "Limit": 2 })
resp = APIRequest(url, urlParams)
data = getJson(resp)
if data <> invalid and data.Items.Count() = 2 then
' remove finished video node
n = m.scene.getChildCount() - 1
m.scene.removeChildIndex(n)
' setup new video node
nextVideo = CreateVideoPlayerGroup(data.Items[1].Id)
m.scene.appendChild(nextVideo)
nextVideo.setFocus(true)
nextVideo.control = "play"
ReportPlayback(nextVideo, "start")
function autoPlayNextEpisode(videoID as string, showID as string)
' use web client setting
if m.user.Configuration.EnableNextEpisodeAutoPlay then
' query API for next episode ID
url = Substitute("Shows/{0}/Episodes", showID)
urlParams = { "UserId": get_setting("active_user")}
urlParams.Append({ "StartItemId": videoID })
urlParams.Append({ "Limit": 2 })
resp = APIRequest(url, urlParams)
data = getJson(resp)
if data <> invalid and data.Items.Count() = 2 then
' remove finished video node
n = m.scene.getChildCount() - 1
m.scene.removeChildIndex(n)
' setup new video node
nextVideo = CreateVideoPlayerGroup(data.Items[1].Id)
m.scene.appendChild(nextVideo)
nextVideo.setFocus(true)
nextVideo.control = "play"
ReportPlayback(nextVideo, "start")
else
' can't play next episode
RemoveCurrentGroup()
end if
else
' can't play next episode
RemoveCurrentGroup()
end if
end function