Merge pull request #317 from cewert/autoplay-episodes
Auto play the next TV episode
This commit is contained in:
commit
d165eee661
|
@ -13,6 +13,7 @@
|
||||||
<field id="decodeAudioSupported" type="boolean" />
|
<field id="decodeAudioSupported" type="boolean" />
|
||||||
<field id="isTranscoded" type="boolean" />
|
<field id="isTranscoded" type="boolean" />
|
||||||
<field id="systemOverlay" type="boolean" value="false" />
|
<field id="systemOverlay" type="boolean" value="false" />
|
||||||
|
<field id="showID" type="string" />
|
||||||
</interface>
|
</interface>
|
||||||
<script type="text/brightscript" uri="JFVideo.brs" />
|
<script type="text/brightscript" uri="JFVideo.brs" />
|
||||||
<children>
|
<children>
|
||||||
|
|
|
@ -62,6 +62,7 @@ sub Main()
|
||||||
n = m.scene.getChildCount() - 1
|
n = m.scene.getChildCount() - 1
|
||||||
if msg.getRoSGNode().focusedChild <> invalid and msg.getRoSGNode().focusedChild.isSubtype("JFVideo")
|
if msg.getRoSGNode().focusedChild <> invalid and msg.getRoSGNode().focusedChild.isSubtype("JFVideo")
|
||||||
stopPlayback()
|
stopPlayback()
|
||||||
|
RemoveCurrentGroup()
|
||||||
else
|
else
|
||||||
if n = 1 then return
|
if n = 1 then return
|
||||||
RemoveCurrentGroup()
|
RemoveCurrentGroup()
|
||||||
|
@ -397,6 +398,12 @@ sub Main()
|
||||||
video = msg.getRoSGNode()
|
video = msg.getRoSGNode()
|
||||||
if video.position >= video.duration and not video.content.live then
|
if video.position >= video.duration and not video.content.live then
|
||||||
stopPlayback()
|
stopPlayback()
|
||||||
|
if video.showID = invalid then
|
||||||
|
RemoveCurrentGroup()
|
||||||
|
else
|
||||||
|
MarkItemWatched(video.id)
|
||||||
|
playNextEpisode(video.id, video.showID)
|
||||||
|
end if
|
||||||
end if
|
end if
|
||||||
else if isNodeEvent(msg, "fire")
|
else if isNodeEvent(msg, "fire")
|
||||||
ReportPlayback(group, "update")
|
ReportPlayback(group, "update")
|
||||||
|
@ -404,6 +411,11 @@ sub Main()
|
||||||
node = msg.getRoSGNode()
|
node = msg.getRoSGNode()
|
||||||
if node.state = "finished" then
|
if node.state = "finished" then
|
||||||
stopPlayback()
|
stopPlayback()
|
||||||
|
if node.showID = invalid then
|
||||||
|
RemoveCurrentGroup()
|
||||||
|
else
|
||||||
|
playNextEpisode(node.id, node.showID)
|
||||||
|
end if
|
||||||
else if node.state = "playing" or node.state = "paused" then
|
else if node.state = "playing" or node.state = "paused" then
|
||||||
ReportPlayback(group, "update")
|
ReportPlayback(group, "update")
|
||||||
end if
|
end if
|
||||||
|
|
|
@ -20,7 +20,8 @@ function VideoContent(video, audio_stream_idx = 1) as object
|
||||||
params = {}
|
params = {}
|
||||||
|
|
||||||
meta = ItemMetaData(video.id)
|
meta = ItemMetaData(video.id)
|
||||||
video.content.title = meta.Name
|
video.content.title = meta.title
|
||||||
|
video.showID = meta.showID
|
||||||
|
|
||||||
' If there is a last playback positon, ask user if they want to resume
|
' If there is a last playback positon, ask user if they want to resume
|
||||||
position = meta.json.UserData.PlaybackPositionTicks
|
position = meta.json.UserData.PlaybackPositionTicks
|
||||||
|
@ -310,13 +311,11 @@ end function
|
||||||
|
|
||||||
function StopPlayback()
|
function StopPlayback()
|
||||||
video = m.scene.focusedchild
|
video = m.scene.focusedchild
|
||||||
|
if video.state = "finished" then MarkItemWatched(video.id)
|
||||||
video.control = "stop"
|
video.control = "stop"
|
||||||
m.device.EnableAppFocusEvent(False)
|
m.device.EnableAppFocusEvent(False)
|
||||||
video.findNode("playbackTimer").control = "stop"
|
video.findNode("playbackTimer").control = "stop"
|
||||||
video.visible = "false"
|
|
||||||
if video.status = "finished" then MarkItemWatched(video.id)
|
|
||||||
ReportPlayback(video, "stop")
|
ReportPlayback(video, "stop")
|
||||||
RemoveCurrentGroup()
|
|
||||||
end function
|
end function
|
||||||
|
|
||||||
function displaySubtitlesByUserConfig(subtitleTrack, audioTrack)
|
function displaySubtitlesByUserConfig(subtitleTrack, audioTrack)
|
||||||
|
@ -337,3 +336,28 @@ function displaySubtitlesByUserConfig(subtitleTrack, audioTrack)
|
||||||
return false
|
return false
|
||||||
end if
|
end if
|
||||||
end function
|
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")
|
||||||
|
else
|
||||||
|
' can't play next episode
|
||||||
|
RemoveCurrentGroup()
|
||||||
|
end if
|
||||||
|
end function
|
Loading…
Reference in New Issue
Block a user