- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
In Roku Brighscript: How to refresh a video scene if/when HSL streaming stops playing?
I have this very simple roku app, with this single video scene to play the live m3u8 stream forever. But eventually then video freezes. Is it possible to detect the video is not playing, destroy and recreate the videocontent ?
```
<?xml version = "1.0" encoding = "utf-8" ?>
<component name = "VideoExample" extends = "Scene" >
<script type = "text/brightscript" >
<![CDATA[
sub init()
videocontent = createObject("RoSGNode", "ContentNode")
videocontent.live = true
videocontent.PlayStart = 999999999
videocontent.streamformat = "hls"
videocontent.url = "my_m3u8_url"
video = m.top.findNode("exampleVideo")
video.content = videocontent
video.setFocus(true)
video.control = "play"
end sub
]]>
</script>
<children >
<Video id = "exampleVideo"/>
</children>
</component>
```
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Re: In Roku Brighscript: How to refresh a video scene if/when HSL streaming stops playing?
You will need to add an observer to detect changes to the "state" field.
eg:
First assign your 'video' variable as 'm.video' so it can be accessed in the state event ...
m.video.observeField("state", "onVideoState")
'....
sub onVideoState()
if m.video.state = "finished"
' reset the video content or just play the video again... etc.
' m.video.control = "play"
end if
end sub