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

Live Stream Offline Image

I am a beginner with this and I need help! I am switching live streaming services. We only stream our service once a week, so for the majority of the time, our live stream is not active. My previous stream host streamed an offline loop to the HLS stream, however, my new stream host does not do this. I need to see if there is any way to do this within the roku code. Here is how my current live stream is hard coded into the channel:
Function showHomeScreen(screen) As Integer

if validateParam(screen, "roPosterScreen", "showHomeScreen") = false return -1

initCategoryList()
screen.SetContentList(m.Categories.Kids)
screen.SetFocusedListItem(0)
screen.Show()

while true
msg = wait(0, screen.GetMessagePort())
if type(msg) = "roPosterScreenEvent" then
print "showHomeScreen | msg = "; msg.GetMessage() " | index = "; msg.GetIndex()
if msg.isListFocused() then
print "list focused | index = "; msg.GetIndex(); " | category = "; m.curCategory
else if msg.isListItemSelected() then
print "list item selected | index = "; msg.GetIndex()
kid = m.Categories.Kids[msg.GetIndex()]

if kid.type = "About Us" then
ShowParagraphScreen()

else if kid.type = "Hope Point Live Stream" then

' method 1: hard code the stream here in the channel
' init the video item now and go to video:
item = init_show_feed_item()
item.StreamBitrates.Push(2000)
item.StreamQualities.Push("SD")
item.StreamFormat = "hls"
item.StreamUrls.Push(validstr("http://www.yourstreamlive.com/live/901/hls"))

showVideoScreen(item)



else if kid.Title = "Hope Point Live Stream"

' method 2: key it off some element in the xml so you can update the stream later
' try to get the video item from the kid's xml and play it now
shows = getShowsForCategoryItem(kid, 0)
showVideoScreen(shows[0])

else
displayCategoryPosterScreen(kid)
end if
else if msg.isScreenClosed() then
return -1
end if
end If
end while

return 0

End Function


Is it possible to have a fallback image or something, that tells the channel to check the HLS stream first and then fall back to image if no stream is active?
0 Kudos
2 REPLIES 2
RokuJoel
Binge Watcher

Re: Live Stream Offline Image

Look for msg.isRequestFailed() and if it is, then load an imageCanvas and show a poster image, of course you will need to listen for the back-button and up button events to exit the roImageCanvasScreen.

- Joel
0 Kudos
jmatt0806
Channel Surfer

Re: Live Stream Offline Image

"hpdean" wrote:
I am a beginner with this and I need help!  I am switching live streaming services.  We only stream our service once a week, so for the majority of the time, our live stream is not active.  My previous stream host streamed an offline loop to the HLS stream, however, my new stream host does not do this.  I need to see if there is any way to do this within the roku code.  Here is how my current live stream is hard coded into the channel:
Function showHomeScreen(screen) As Integer

   if validateParam(screen, "roPosterScreen", "showHomeScreen") = false return -1

   initCategoryList()
   screen.SetContentList(m.Categories.Kids)
   screen.SetFocusedListItem(0)
   screen.Show()

   while true
       msg = wait(0, screen.GetMessagePort())
       if type(msg) = "roPosterScreenEvent" then
           print "showHomeScreen | msg = "; msg.GetMessage() " | index = "; msg.GetIndex()
           if msg.isListFocused() then
               print "list focused | index = "; msg.GetIndex(); " | category = "; m.curCategory
           else if msg.isListItemSelected() then
               print "list item selected | index = "; msg.GetIndex()
               kid = m.Categories.Kids[msg.GetIndex()]

if kid.type = "About Us" then
                   ShowParagraphScreen()

else if kid.type = "Hope Point Live Stream" then

' method 1: hard code the stream here in the channel
' init the video item now and go to video:
item = init_show_feed_item()
item.StreamBitrates.Push(2000)
item.StreamQualities.Push("SD")
item.StreamFormat = "hls"
item.StreamUrls.Push(validstr("http://www.yourstreamlive.com/live/901/hls"))

showVideoScreen(item)



else if kid.Title = "Hope Point Live Stream"

' method 2: key it off some element in the xml so you can update the stream later
' try to get the video item from the kid's xml and play it now
shows = getShowsForCategoryItem(kid, 0)
showVideoScreen(shows[0])

else
displayCategoryPosterScreen(kid)
               end if
           else if msg.isScreenClosed() then
               return -1
           end if
       end If
   end while

   return 0

End Function


Is it possible to have a fallback image or something, that tells the channel to check the HLS stream first and then fall back to image if no stream is active?

I see if your channel you have a dialog pop-up if the stream isn't active. How did you end up doing this?
Thanks
0 Kudos