Check if next episode exists when content changes
This commit is contained in:
parent
a762e65a75
commit
a0c0a7c3ac
13
components/GetNextEpisodeTask.brs
Normal file
13
components/GetNextEpisodeTask.brs
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
sub init()
|
||||||
|
m.top.functionName = "getNextEpisodeTask"
|
||||||
|
end sub
|
||||||
|
|
||||||
|
sub getNextEpisodeTask()
|
||||||
|
m.nextEpisodeData = api_API().shows.getepisodes(m.top.showID, {
|
||||||
|
UserId: get_setting("active_user"),
|
||||||
|
StartItemId: m.top.videoID,
|
||||||
|
Limit: 2
|
||||||
|
})
|
||||||
|
|
||||||
|
m.top.nextEpisodeData = m.nextEpisodeData
|
||||||
|
end sub
|
12
components/GetNextEpisodeTask.xml
Normal file
12
components/GetNextEpisodeTask.xml
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
|
|
||||||
|
<component name="GetNextEpisodeTask" extends="Task">
|
||||||
|
<interface>
|
||||||
|
<field id="videoID" type="string" />
|
||||||
|
<field id="showID" type="string" />
|
||||||
|
<field id="nextEpisodeData" type="assocarray" />
|
||||||
|
</interface>
|
||||||
|
<script type="text/brightscript" uri="GetNextEpisodeTask.brs" />
|
||||||
|
<script type="text/brightscript" uri="pkg:/source/utils/config.brs" />
|
||||||
|
<script type="text/brightscript" uri="pkg:/source/roku_modules/api/api.brs" />
|
||||||
|
</component>
|
|
@ -27,12 +27,33 @@ end sub
|
||||||
|
|
||||||
' Event handler for when video content field changes
|
' Event handler for when video content field changes
|
||||||
sub onContentChange()
|
sub onContentChange()
|
||||||
|
if not isValid(m.top.content) then return
|
||||||
|
|
||||||
m.top.observeField("position", "onPositionChanged")
|
m.top.observeField("position", "onPositionChanged")
|
||||||
'check if episode has a next episode
|
|
||||||
|
|
||||||
' If video content type is not episode, remove position observer
|
' If video content type is not episode, remove position observer
|
||||||
if m.top.content.contenttype <> 4
|
if m.top.content.contenttype <> 4
|
||||||
m.top.unobserveField("position")
|
m.top.unobserveField("position")
|
||||||
|
return
|
||||||
|
end if
|
||||||
|
|
||||||
|
' Check if next episde is available
|
||||||
|
if isValid(m.top.showID)
|
||||||
|
if m.top.showID <> ""
|
||||||
|
m.getNextEpisodeTask = createObject("roSGNode", "GetNextEpisodeTask")
|
||||||
|
m.getNextEpisodeTask.showID = m.top.showID
|
||||||
|
m.getNextEpisodeTask.videoID = m.top.id
|
||||||
|
m.getNextEpisodeTask.observeField("nextEpisodeData", "onNextEpisodeDataLoaded")
|
||||||
|
m.getNextEpisodeTask.control = "RUN"
|
||||||
|
end if
|
||||||
|
end if
|
||||||
|
end sub
|
||||||
|
|
||||||
|
sub onNextEpisodeDataLoaded()
|
||||||
|
if m.getNextEpisodeTask.nextEpisodeData.items.count() = 1
|
||||||
|
print "No Next Episode Available"
|
||||||
|
else
|
||||||
|
print "Next Episode Found"
|
||||||
end if
|
end if
|
||||||
end sub
|
end sub
|
||||||
|
|
||||||
|
@ -109,14 +130,6 @@ sub onState(msg)
|
||||||
m.top.control = "stop"
|
m.top.control = "stop"
|
||||||
m.top.backPressed = true
|
m.top.backPressed = true
|
||||||
else if m.top.state = "playing"
|
else if m.top.state = "playing"
|
||||||
params = { "UserId": get_setting("active_user"), "adjacentTo": m.top.id }
|
|
||||||
series = m.top.showID
|
|
||||||
nextEpisode = api_API().shows.getepisodes(series, params)
|
|
||||||
print nextEpisode
|
|
||||||
if isValid(nextEpisode)
|
|
||||||
print nextEpisode
|
|
||||||
end if
|
|
||||||
|
|
||||||
if m.playReported = false
|
if m.playReported = false
|
||||||
ReportPlayback("start")
|
ReportPlayback("start")
|
||||||
m.playReported = true
|
m.playReported = true
|
||||||
|
|
Loading…
Reference in New Issue
Block a user