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: 
scud
Visitor

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 1
RokuKevin
Visitor

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.

--Kevin



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

p = CreateObject("roMessagePort")
video = CreateObject("roVideoScreen")
video.setMessagePort(p)
bitrates = [0] ' 0 = no dots
urls = ["http://devimages.apple.com/iphone/samples/bipbop/bipbopall.m3u8"]
qualities = ["SD"]

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

video.SetContent(videoclip)
video.show()

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()
else
print "Unknown event: "; msg.GetType(); " msg: "; msg.GetMessage()
endif
end if
end while

screenFacade.showMessage("")
sleep(25)
End Sub
0 Kudos