You would have to have something to parse it like:
if xml.parse(data)
videos=[]
for each object in xml.media
video={}
video.streamquality=[object.streamquality.gettext()]
video.streambitrate=[object.streambitrate.gettext().toint()]
video.streamurl=[object.streamurl.gettext]
videos.push(video)
end for
end if
video.SwitchingStrategy="full-adaptation"
and then feed that into your video playback function. But you should ideally have more data than just the videos, such as title, shortdescriptionLine1 and thumbnail images.
also, you need to check the device mode - if SDTV mode you would override the streamQuality with [“SD”] or playback will fail in SDTV mode.
Actually for HLS, you should NOT specify multiple URLs. You should put the URLs for the different streams in the top-level m3u8 as specified by the HLS spec, and pass that one URL to the video player. This allows the player to dynamically switch bitrates.
I am new to ROKU and using SampleVideoPlayer code to test my HLS streams. Even though, I have 6 different bit rates in my playlist.m3u8 file, ROKU picks the low quality stream and is not switching to high bit rate. I have enough internet bandwidth to use high quality stream.
Below is the section of code, which loads the streams from XML file:
e = curShow.media[0]
if e <> invalid then
item.StreamBitrates.Push(strtoi(validstr(e.streamBitrate.GetText())))
item.StreamQualities.Push(validstr(e.streamQuality.GetText()))
item.StreamUrls.Push(validstr(e.streamUrl.GetText()))
endif
Make sure you are setting the SwitchingStrategy value. A bug was introduced a few firmwares ago that would prevent HLS from switching to a higher bitrate if the SwitchingStrategy wasn’t set. I don’t know if that bug was ever fixed, but it’s best to always set that value.
“TheEndless” wrote:
Make sure you are setting the SwitchingStrategy value. A bug was introduced a few firmwares ago that would prevent HLS from switching to a higher bitrate if the SwitchingStrategy wasn’t set. I don’t know if that bug was ever fixed, but it’s best to always set that value.
Thank you. It worked. I am using SwitchingStrategy as “full-adaptation”.
Another question - As I mentioned above, I am using HLS streams from Wowza server, which has 6 variants from 150k to 3600k. I read in the documentation that, the dots/HD symbol is not displayed, if the stream is HLS. Is there any way to display HD if any of the variant is of HD quality?
I am using “0” as StreamBitrates in XML.
Any other suggestions for quick switching/buffering/scrubbling?
Do you have a simple live streaming zip, an example which I can build on for live streaming studies? Similar to simple video player?
Sometimes, solutions have a way of staring in my face and I am not able to see it.
Appreciate all the help!
Here’s a simplified version of simplevideoplayer code: that should work to stream a live stream:
sub main()
print "Displaying video: "
p = CreateObject("roMessagePort")
video = CreateObject("roVideoScreen")
video.setMessagePort(p)
videoclip = CreateObject("roAssociativeArray")
videoclip.StreamBitrates = [0]
videoclip.StreamUrls = ["http://myserver.com/mylivestream.m3u8"]
di = CreateObject("roDeviceInfo")
if di.GetDisplayType() = "HDTV" then
videoclip.streamqualities=["HD"]
else
videoclip.streamqualities=["SD"]
end if
videoclip.StreamFormat = "hls"
videoclip.Title = "my awesome live stream"
videoclip.SubtitleUrl = ""
videoclip.switchingstrategy="full-adaptation"
video.SetContent(videoclip)
video.show()
lastSavedPos = 0
statusInterval = 10
while true
msg = wait(0, video.GetMessagePort())
if type(msg) = "roVideoScreenEvent"
if msg.isScreenClosed() then 'ScreenClosed event
print "Closing video screen"
return
exit while
else if msg.isPlaybackPosition() then
nowpos = msg.GetIndex()
if nowpos > 10000
end if
if nowpos > 0
if abs(nowpos - lastSavedPos) > statusInterval
lastSavedPos = nowpos
end if
end if
else if msg.isRequestFailed()
print "play failed: "; msg.GetMessage()
else
print "Unknown event: "; msg.GetType(); " msg: "; msg.GetMessage()
endif
end if
end while
end sub
Hello everyone. After reading this post, its clear to me that Roku2 can play multibitrate HLS playlist. However, I am new to Roku and I don’t understand how to make this happen. I am using Wowza v3.1.2 and my HLS adaptive bit rate URL (playlist.m3u8) works fine on Apple iphone, ipad and android devices. However, the same URL is not working on Roku 2. One more point, single stream (single bit rate) from same Wowza server works fine on this same Roku 2. What am i doing wrong or what do i need to do, to publish the multi-bitrate HLS playlist to a Roku 2.
“TheEndless” wrote:
Make sure you are setting the SwitchingStrategy value. A bug was introduced a few firmwares ago that would prevent HLS from switching to a higher bitrate if the SwitchingStrategy wasn’t set. I don’t know if that bug was ever fixed, but it’s best to always set that value.
Thank you. It worked. I am using SwitchingStrategy as “full-adaptation”.
Another question - As I mentioned above, I am using HLS streams from Wowza server, which has 6 variants from 150k to 3600k. I read in the documentation that, the dots/HD symbol is not displayed, if the stream is HLS. Is there any way to display HD if any of the variant is of HD quality?
I am using “0” as StreamBitrates in XML.
Any other suggestions for quick switching/buffering/scrubbling?
Thank you!
I am having the same issue like the creator of this thread but since I am very new to the topic, I could not figure the solution for the problem from the answers.
What is the code for the “SwitchingStrategy”? How do I do that?
I also point HLS streams to the playlist.m3u8 file and the Roku insists on choosing the stream with the lowest bitrate Thanks in advance!
That code will be placed in the showFeed.brs if using videoplayer. Search for the first line here and add the rest.
If item.StreamFormat="" 'set default streamFormat to mp4 if doesn't exist in xml
item.StreamFormat="mp4"
End If
If item.StreamFormat="hls"
item.SwitchingStrategy="full-adaptation"
End If
probably should put that after the item.StreamFormat= line.
Then you should be able to control which switching strategy is used by your channel on a per-item basis.
You can put whatever you want in your XML, as long as it is valid xml, and you have an xml parser to decode it, you can control your channel completely from your server.