是否有一种简单的方法可以检查HLS(M3U8)流是否可用,如果没有则显示错误消息?我正在使用以下代码播放M3U8流,但如果流不可用,则“检索”消息将无限期显示。
如果流未启动,我想立即显示错误。
sub onButtonSelected()
'Ok'
if m.ButtonGroup.buttonSelected = 0
m.Video.visible = "true"
m.Video.control = "play"
m.Video.setFocus(true)
'Add error message logic here if stream doesn't play
'Exit button pressed'
else
m.Exiter.control = "RUN"
end if
end sub
答案 0 :(得分:0)
您应该观察视频播放器的状态。
sub onButtonSelected()
'Ok'
if m.ButtonGroup.buttonSelected = 0
m.Video.visible = "true"
' This observer should not be set here because it will add new observer every time you
' select the button. For demonstration purposes only.
m.video.observeField("state", "onVideoStateChanged")
m.Video.control = "play"
m.Video.setFocus(true)
'Exit button pressed'
else
m.Exiter.control = "RUN"
end if
end sub
sub onVideoStateChanged(event as Object)
if event.getData() = "error"
' Show error dialog here
end if
end sub
您还可以通过查看视频节点的 errorMsg / errorCode 字段来查看错误消息/代码。