Hi all,
I am new to Roku development. I have a project where we are using a Roku to loop through a series of videos on a TV. The playlist is retrieved via REST API and then the looping starts.
In my code, what I really want to do is just load a video player, then have it play one video after the next. However, there does not seem to be a way to have the player play another video when it finishes. As written it exits before playing the next one.
Function startVideo()
p = CreateObject("roMessagePort")
videoScreen = CreateObject("roVideoScreen")
videoScreen.setMessagePort(p)
videoScreen.show()
while true
print "Refreshing video list..."
playlist = CreateObject("roArray", 10, true)
mediaInfo = getMediaInfoForProject("2246141")
for each media in mediaInfo
'media.id
'media.name
'media.desc
'media.type
'media.thumb
videoURL = getVideoForID(Stri(media.id).Trim())
media.videoURL = videoURL
playlist.push(media)
end for
for each media in playlist
print "next video is ";media.name
videoclip = CreateObject("roAssociativeArray")
videoclip.StreamBitrates = [0] ' 0 = no dots, adaptive bitrate
videoclip.StreamUrls = [media.videoURL]
videoclip.StreamQualities = ["HD"]
videoclip.StreamFormat = "mp4"
videoclip.Title = "" ' this is what is shown when the video is loading
videoScreen.SetContent(videoclip)
while true
msg = wait(0, videoScreen.GetMessagePort())
if type(msg) = "roVideoScreenEvent"
if msg.isScreenClosed() then 'ScreenClosed event
print "Screen closed, Completing video"
exit while
else if msg.isFullResult()
print "playback completed"
exit while
else if msg.isStreamStarted()
print "playback started"
else if msg.isRequestFailed()
print "play failed: "; msg.GetMessage()
else if msg.isStatusMessage()
print "status="; msg.GetMessage();" type=" msg.GetType()
else if msg.GetType() = 15
print "Interrupted by user hitting a button on the remote"
else
print "Unknown event: "; msg.GetType(); " msg: "; msg.GetMessage()
endif
end if
end while
print "One done, what's next?"
end for
end while
End Function
What I see in the debug console is this:
Refreshing video list...
next video is video4
playback started
playback completed
One done, what's next?
next video is video2
But video2 never plays, and it returns to the home screen. Help?