Roku Developer Program

Developers and content creators—a complete solution for growing an audience directly.
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Level 7

sample script

I have downloaded and viewed the appMain.brs. sample script, but can't make one work.
If I wanted to view for example only the Apple HLS test stream, how would I create the script?
0 Kudos
1 Reply
Level 9

Re: sample script

You just need to set the StreamFormat to "hls" and a single element in the urls array to the .m3u8 file.

See the code below.


Sub Main()
screenFacade = CreateObject("roPosterScreen")

p = CreateObject("roMessagePort")
video = CreateObject("roVideoScreen")
bitrates = [0] ' 0 = no dots
urls = [""]
qualities = ["SD"]

videoclip = CreateObject("roAssociativeArray")
videoclip.StreamBitrates = bitrates
videoclip.StreamUrls = urls
videoclip.StreamQualities = qualities
videoclip.StreamFormat = "hls"
videoclip.Title = "Apple Sample HLS Stream"


lastSavedPos = 0
statusInterval = 10 'position must change by more than this number of seconds before saving

while true
msg = wait(0, video.GetMessagePort())
if type(msg) = "roVideoScreenEvent"
if msg.isScreenClosed() then 'ScreenClosed event
print "Closing video screen"
exit while
else if msg.isPlaybackPosition() then
nowpos = msg.GetIndex()
if nowpos > 10000

end if
if nowpos > 0
if abs(nowpos - lastSavedPos) > statusInterval
lastSavedPos = nowpos
end if
end if
else if msg.isRequestFailed()
print "play failed: "; msg.GetMessage()
print "Unknown event: "; msg.GetType(); " msg: "; msg.GetMessage()
end if
end while

End Sub
0 Kudos