Roku Developer Program

Join our online forum to talk to Roku developers and fellow channel creators. Ask questions, share tips with the community, and find helpful resources.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
ov2015
Visitor

Play videos as playlist

Hi

I have a list of mp4 videos that has to be played one after another. For a certain category of mp4 videos, I am using "roPosterScreen" to display all the videos and "roVideoScreen" to play my videos. Once the user starts playing the video, I would like to play all the videos in that category one after the another without stopping, like a playlist.

I kind of partly achieved it but the problem is once every video is complete, it goes back to "roPosterScreen" video list screen and soon starts the next video. Between every video there is a flicker of previous screen before it moves to second video. I have to close the "roVideoScreen" for each video and open it again for the next, this should be the reason. I have copied major part of my code below.


this = {
videoScreen: CreateObject("roPosterScreen")
videoScreenPort: CreateObject("roMessagePort")
videos: video_array
}
this.videoScreen.SetMessagePort(this.videoScreenPort)
this.videoScreen.SetContentList(this.videos)
this.videoScreen.Show()

while(true)
msg = wait(0,this.videoScreenPort)
if (type(msg) = "roPosterScreenEvent")
if (msg.IsListItemSelected())
For index = msg.GetIndex() To this.videos.count()-1 Step +1
PlayVideo(this.videos[index])
End For
...

Function PlayVideo(video as object) as integer
videoScreen = CreateObject("roVideoScreen")
port = CreateObject("roMessagePort")
videoScreen.SetMessagePort( port )

metaData = {
Stream: {
Url: video.Url
}
StreamFormat: "mp4"
}
videoScreen.SetContent( metaData )
videoScreen.show()

while (true)
msg = wait(0, port)
if type(msg) = "roVideoScreenEvent"
if (msg.isScreenClosed())
return -1
else if msg.isFullResult()
print "playback completed"
exit while
end if
endif
end while
End Function


I checked ROKU samples for "roVideoPlayer" where it can play a playlist but it lacks the user control that I would like in my videos.

Any Suggestions would be great
0 Kudos
2 REPLIES 2
belltown
Roku Guru

Re: Play videos as playlist

You can display a blank facade before playing a sequence of videos, so in-between videos you'll just see blackness instead of the poster screen:


'
' User presses Play All button, then ...
'
facade = CreateObject ("roImageCanvas")
facade.SetLayer (0, {Color: "#FF000000"})
facade.Show ()
'
' Play Videos ...
'
facade.Close()
0 Kudos
ov2015
Visitor

Re: Play videos as playlist

"belltown" wrote:
You can display a blank facade before playing a sequence of videos, so in-between videos you'll just see blackness instead of the poster screen:


'
' User presses Play All button, then ...
'
facade = CreateObject ("roImageCanvas")
facade.SetLayer (0, {Color: "#FF000000"})
facade.Show ()
'
' Play Videos ...
'
facade.Close()


I bet this will do for me, just had a quick look about facade. Thanks a lot 😄
0 Kudos
Need Assistance?
Welcome to the Roku Community! Feel free to search our Community for answers or post your question to get help.

Become a Roku Streaming Expert!

Share your expertise, help fellow streamers, and unlock exclusive rewards as part of the Roku Community. Learn more.