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: 
jmatt0806
Channel Surfer

Show Error Message If Stream Is Not Available?

How can I check if an HLS (M3U8)  stream is available and if not show an error dialog?

Here's the code I'm using to play the video:


sub onButtonSelected()
  'Ok'
  if m.ButtonGroup.buttonSelected = 0
    m.Video.visible = "true"
    m.Video.control = "play"
    m.Video.setFocus(true)
  'Exit button pressed'
  else
    m.Exiter.control = "RUN"
  end if
end sub
0 Kudos
1 REPLY 1
24i
Streaming Star

Re: Show Error Message If Stream Is Not Available?

Hi jmatt0806,

The way we do it is by observing the video player state variable.

m.Video.observeField("state", "videoPlayerStateChanged")

Sub videoPlayerStateChanged()
    state = m.Video.state
    print "Video player state is now: " + state

    if(state = "error")
        print "ERROR - Code " + m.Video.errorCode.ToStr() + ", Message: " + m.Video.errorMsg
   end if
End Sub

And more info on dialogs can be found here: https://sdkdocs.roku.com/display/sdkdoc/Dialog
Hope this helps
0 Kudos
Need Assistance?
Welcome to the Roku Community! Feel free to search our Community for answers or post your question to get help.

Become a Roku Streaming Expert!

Share your expertise, help fellow streamers, and unlock exclusive rewards as part of the Roku Community. Learn more.