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

Livestream Channel example?

Hi. I am new to Roku development.

I have successfully published a few example channels using the SDK example templates, but have not yet figured out how to publish a channel with a live video stream.

Can anyone point me to the right part of the documentation that describes this, or a post in this forum, or the proper example code?

Thanks so much for your time and for this forum.
0 Kudos
8 REPLIES 8
OddScott
Roku Guru

Re: Livestream Channel example?

Here's something from just a few days ago...
http://forums.roku.com/viewtopic.php?f=34&t=53878
www.InstantTvChannel.com - 717-441-4386 - Build a Roku SDK channel in 15 minutes! - Easy Direct Publisher to SDK upgrades!
0 Kudos
pwagner3
Visitor

Re: Livestream Channel example?

Thanks for the reply. I am really just trying to figure out how to make an HLS work.

I am publishing the simplevideoplayer package and cannot get the bipbop Apple Test or the BigBuckBunny videos to run on my published channel.
My channel looks good when I add it to my channel lineup, but when I select "Play" nothing happens.

Does anyone have a working example of the simplevideoplayer appMain file that they could share?
0 Kudos
bandal
Visitor

Re: Livestream Channel example?

Try this and cut & paste all. The HLS Video is only like 1000kbps at 1 rate. But works for your test. Big Buck must be down it didn't work here either. If you want a real live stream insert this hls link instead of mine. http://www.nasa.gov/multimedia/nasatv/N ... c-IPS.m3u8
' ********************************************************************
' ** Sample PlayVideo App
' ** Copyright (c) 2009 Roku Inc. All Rights Reserved.
' ********************************************************************

Sub Main(args As Dynamic)
'initialize theme attributes like titles, logos and overhang color
initTheme()

if type(args) = "roAssociativeArray" and type(args.url) = "roString" then
displayVideo(args)
end if
print "Type args = "; type(args)
print "Type args.url = "; type(args.url)

'has to live for the duration of the whole app to prevent flashing
'back to the roku home screen.
screenFacade = CreateObject("roPosterScreen")
screenFacade.show()

itemMpeg4 = { ContentType:"episode"
SDPosterUrl:"file://pkg:/images/DanGilbert.jpg"
HDPosterUrl:"file://pkg:/images/DanGilbert.jpg"
IsHD:False
HDBranded:False
ShortDescriptionLine1:"Dan Gilbert asks, Why are we happy?"
ShortDescriptionLine2:""
Description:"Harvard psychologist Dan Gilbert says our beliefs about what will make us happy are often wrong -- a premise he supports with intriguing research, and explains in his accessible and unexpectedly funny book, Stumbling on Happiness."
Rating:"NR"
StarRating:"80"
Length:1280
Categories:["Technology","Talk"]
Title:"Dan Gilbert asks, Why are we happy?"
}

itemVenter = { ContentType:"episode"
SDPosterUrl:"file://pkg:/images/CraigVenter-2008.jpg"
HDPosterUrl:"file://pkg:/images/CraigVenter-2008.jpg"
IsHD:False
HDBranded:False
ShortDescriptionLine1:"Can we create new life out of our digital universe?"
ShortDescriptionLine2:""
Description:"He walks the TED2008 audience through his latest research into fourth-generation fuels -- biologically created fuels with CO2 as their feedstock. His talk covers the details of creating brand-new chromosomes using digital technology, the reasons why we would want to do this, and the bioethics of synthetic life. A fascinating Q&A with TED's Chris Anderson follows."
Rating:"NR"
StarRating:"80"
Length:1972
Categories:["Technology","Talk"]
Title:"Craig Venter asks, Can we create new life out of our digital universe?"
}

item = { ContentType:"episode"
SDPosterUrl:"file://pkg:/images/BigBuckBunny.jpg"
HDPosterUrl:"file://pkg:/images/BigBuckBunny.jpg"
IsHD:true
HDBranded:true
ShortDescriptionLine1:"Big Buck Bunny"
ShortDescriptionLine2:""
Description:"Bali Trip 2011 is being served using my ISP server via HLS HTTP Live Streaming."
Rating:"NR"
StarRating:"80"
Length:600
Categories:["Technology","Cartoon"]
Title:"Bali Trip 2011"
}

'showSpringboardScreen(itemVenter)
'showSpringboardScreen(itemMpeg4) 'uncomment this line and comment out the next to see the old mpeg4 example
showSpringboardScreen(item) 'uncomment this line to see the BaliTrip example

'exit the app gently so that the screen doesn't flash to black
screenFacade.showMessage("")
sleep(25)
End Sub

'*************************************************************
'** Set the configurable theme attributes for the application
'**
'** Configure the custom overhang and Logo attributes
'*************************************************************

Sub initTheme()

app = CreateObject("roAppManager")
theme = CreateObject("roAssociativeArray")

theme.OverhangPrimaryLogoOffsetSD_X = "72"
theme.OverhangPrimaryLogoOffsetSD_Y = "15"
theme.OverhangSliceSD = "pkg:/images/Overhang_BackgroundSlice_SD43.png"
theme.OverhangPrimaryLogoSD = "pkg:/images/Logo_Overhang_SD43.png"

theme.OverhangPrimaryLogoOffsetHD_X = "123"
theme.OverhangPrimaryLogoOffsetHD_Y = "20"
theme.OverhangSliceHD = "pkg:/images/Overhang_BackgroundSlice_HD.png"
theme.OverhangPrimaryLogoHD = "pkg:/images/Logo_Overhang_HD.png"

'this is an optional theme attribute. the default subtitle color is yellow.
theme.SubtitleColor = "#dc00dc"

app.SetTheme(theme)

End Sub


'*************************************************************
'** showSpringboardScreen()
'*************************************************************

Function showSpringboardScreen(item as object) As Boolean
port = CreateObject("roMessagePort")
screen = CreateObject("roSpringboardScreen")

print "showSpringboardScreen"

screen.SetMessagePort(port)
screen.AllowUpdates(false)
if item <> invalid and type(item) = "roAssociativeArray"
screen.SetContent(item)
endif

screen.SetDescriptionStyle("generic") 'audio, movie, video, generic
' generic+episode=4x3,
screen.ClearButtons()
screen.AddButton(1,"Play")
screen.AddButton(2,"Go Back")
screen.SetStaticRatingEnabled(false)
screen.AllowUpdates(true)
screen.Show()

downKey=3
selectKey=6
while true
msg = wait(0, screen.GetMessagePort())
if type(msg) = "roSpringboardScreenEvent"
if msg.isScreenClosed()
print "Screen closed"
exit while
else if msg.isButtonPressed()
print "Button pressed: "; msg.GetIndex(); " " msg.GetData()
if msg.GetIndex() = 1
displayVideo("")
else if msg.GetIndex() = 2
return true
endif
else
print "Unknown event: "; msg.GetType(); " msg: "; msg.GetMessage()
endif
else
print "wrong type.... type=";msg.GetType(); " msg: "; msg.GetMessage()
endif
end while


return true
End Function


'*************************************************************
'** displayVideo()
'*************************************************************

Function displayVideo(args As Dynamic)
print "Displaying video: "
p = CreateObject("roMessagePort")
video = CreateObject("roVideoScreen")
video.setMessagePort(p)

'bitrates = [0] ' 0 = no dots, adaptive bitrate
'bitrates = [348] ' <500 Kbps = 1 dot
'bitrates = [664] ' <800 Kbps = 2 dots
'bitrates = [996] ' <1.1Mbps = 3 dots
'bitrates = [2048] ' >=1.1Mbps = 4 dots
bitrates = [0]

'Swap the commented values below to play different video clips...
'urls = ["http://video.ted.com/talks/podcast/CraigVenter_2008_480.mp4"]
'qualities = ["HD"]
'StreamFormat = "mp4"
'title = "Craig Venter Synthetic Life"
'srt = "file://pkg:/source/craigventer.srt"

'urls = ["http://video.ted.com/talks/podcast/DanGilbert_2004_480.mp4"]
'qualities = ["HD"]
'StreamFormat = "mp4"
'title = "Dan Gilbert asks, Why are we happy?"

' Apple's HLS test stream
'urls = ["http://devimages.apple.com/iphone/samples/bipbop/bipbopall.m3u8"]
'qualities = ["SD"]
'streamformat = "hls"
'title = "Apple BipBop Test Stream"

' Test HLS from ISP
urls = ["http://www.donggala.org/roku/hls/Bali_HLS.m3u8"]
qualities = ["SD"]
streamformat = "hls"
title = "Test HLS"
srt = ""

if type(args) = "roAssociativeArray"
if type(args.url) = "roString" and args.url <> "" then
urls[0] = args.url
end if
if type(args.StreamFormat) = "roString" and args.StreamFormat <> "" then
StreamFormat = args.StreamFormat
end if
if type(args.title) = "roString" and args.title <> "" then
title = args.title
else
title = ""
end if
if type(args.srt) = "roString" and args.srt <> "" then
srt = args.StreamFormat
else
srt = ""
end if
end if

videoclip = CreateObject("roAssociativeArray")
videoclip.StreamBitrates = bitrates
videoclip.StreamUrls = urls
videoclip.StreamQualities = qualities
videoclip.StreamFormat = StreamFormat
videoclip.Title = title
print "srt = ";srt
if srt <> invalid and srt <> "" then
videoclip.SubtitleUrl = srt
end if

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

0 Kudos
pwagner3
Visitor

Re: Livestream Channel example?

Thank you Bandal. You have been a huge help to me.
I have something up and running now.
I appreciate your time and effort.
You are a blessing!
0 Kudos
bandal
Visitor

Re: Livestream Channel example?

Thanks, here to help if I can.
DA
0 Kudos
AngeloB
Visitor

Re: Livestream Channel example?

the file you have here, where did you paste it, what file?
0 Kudos
AngeloB
Visitor

Re: Livestream Channel example?

Anyone know how to do audio and video HTTP live streaming in the example file 'videoplayer"?
0 Kudos
bandal
Visitor

Re: Livestream Channel example?

Just edit the xml file to show hls versus mp4 in streamFormat and change streamUrl to the HLS file path. Example below, but won't play until you have a valid path to video or audio.

	<item sdImg="http://rokudev.roku.com/rokudev/examples/videoplayer/images/JeffHan.jpg" hdImg="http://rokudev.roku.com/rokudev/examples/videoplayer/images/JeffHan.jpg">
<title>Jeff Han demos his breakthrough touchscreen</title>
<contentId>10061</contentId>
<contentType>Talk</contentType>
<contentQuality>SD</contentQuality>
<streamFormat>hls</streamFormat>
<media>
<streamQuality>SD</streamQuality>
<streamBitrate>1500</streamBitrate>
<streamUrl>http://video.ted.com/talks/podcast/JeffHan_2006_480.m3u8</streamUrl>
</media>
<synopsis>After years of research on touch-driven computer displays, Jeff Han has created a simple, multi-touch, multi-user screen interface that just might herald the end of the point-and-click era.</synopsis>
<genres>Design</genres>
<runtime>531</runtime>
0 Kudos