Roku Developer Program

Developers and content creators—a complete solution for growing an audience directly.
Showing results for 
Show  only  | Search instead for 
Did you mean: 
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()
  if m.ButtonGroup.buttonSelected = 0
    m.Video.visible = "true"
    m.Video.control = "play"
  'Exit button pressed'
    m.Exiter.control = "RUN"
  end if
end sub
0 Kudos
1 REPLY 1\
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:
Hope this helps
0 Kudos