Your Digital Media Has Never Looked So Good

 
scud
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
RokuKevin
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.

--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

Who is online

Users browsing this forum: No registered users and 3 guests