Roku Developer Program

Developers and content creators—a complete solution for growing an audience directly.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
jmatt0806
Level 7

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

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