Your Digital Media Has Never Looked So Good

Topic Author
Posts: 1
Joined: Mon Aug 30, 2010 9:05 am

sample script

Mon Aug 30, 2010 9:13 am

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?
User avatar
Roku Engineering
Posts: 796
Joined: Tue Sep 22, 2009 2:29 pm

Re: sample script

Tue Sep 07, 2010 5:56 pm

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

Who is online

Users browsing this forum: No registered users and 3 guests