I am using the videoplayer example to have channels that are live (hls) and Video on Demand(MP4). I can have only one of them at a time but not both with this example since I had to modify the code to play one format. Is there an example that allows a mix of live and VOD channels ? or can I modify the videoplayer code below to support both? need help since i am not familiar with the roku brightscript syntax.
- Edit appMain.brs and change the line
videoclip.StreamFormat = “mp4”
to
videoclip.StreamFormat = “hls”
once I do that change it only allows hls and vice versa.
please help.
If you obtain the type specifier from the url filename, then it can be a bit more dynamic for you.
ie
videoclip.streamformat=right(episode.streamurl,3)
You don’t even have to change any xml for that. In order to work, the streamformat needs to be set after the streamurl has been.
“destruk” wrote:
If you obtain the type specifier from the url filename, then it can be a bit more dynamic for you.
ie
videoclip.streamformat=right(episode.streamurl,3)
You don’t even have to change any xml for that. In order to work, the streamformat needs to be set after the streamurl has been.
Except that the HLS file extension is .m3u8 so that logic would get you a streamFormat = “3u8”. And if the stream URL has any parameters on it, the result becomes unpredictable. The videoplayer example has support for specifying the streamFormat in the XML starting on line 142 of showFeed.brs.
So if it’s “3u8” then you have your code change it to m3u8, and if there are parameters, do a string comparison for a ? since that’s the first character for any further parameters.
Or, like you said, just change the xml file it parses - but what if you don’t have access or permissions to change the xml file, then how do you do it?
“destruk” wrote:
So if it’s “3u8” then you have your code change it to m3u8, and if there are parameters, do a string comparison for a ? since that’s the first character for any further parameters.
Or, like you said, just change the xml file it parses - but what if you don’t have access or permissions to change the xml file, then how do you do it?
You could do a HEAD request and check the content-type header
That sounds like an excellent solution. Thanks!
Thanks for your help, i need help with the head request code, in rbightscript, how would do a head request cto change the content type ?
Also for unknown reason line # 142 function call for validstr(curShow.streamFormat.GetText()) always returns empty value. I do have a value for the streamFormat in my xml ( see listed below code snipet from creativity). but if i manually set to one type e.g. hls or mp4 then it works for me but i want dynamic setting not hardcoding. your help is really appreciated. thanks in advance.
inside the showfeed.brs file, line #142
'fetch all values from the xml for the current show
item.hdImg = validstr(curShow@hdImg)
item.sdImg = validstr(curShow@sdImg)
item.ContentId = validstr(curShow.contentId.GetText())
item.Title = validstr(curShow.title.GetText())
item.Description = validstr(curShow.description.GetText())
item.ContentType = validstr(curShow.contentType.GetText())
item.ContentQuality = validstr(curShow.contentQuality.GetText())
item.Synopsis = validstr(curShow.synopsis.GetText())
item.Genre = validstr(curShow.genres.GetText())
item.Runtime = validstr(curShow.runtime.GetText())
item.HDBifUrl = validstr(curShow.hdBifUrl.GetText())
item.SDBifUrl = validstr(curShow.sdBifUrl.GetText())
item.StreamFormat = validstr(curShow.streamFormat.GetText())
if item.StreamFormat = “” then 'set default streamFormat to mp4 if doesn’t exist in xml
item.StreamFormat = “mp4”
endif
END OF SAMPLE CODE
Creativity.xml
Creativity.xml CODE:
Elizabeth Gilbert on nurturing creativity
10051
Talk
SD
hls
SD
1500
[http://video.ted.com/talks/podcast/ElizabethGilbert_2009_480.m3u8](http://video.ted.com/talks/podcast/ElizabethGilbert_2009_480.m3u8)
Elizabeth Gilbert
Creativity
1172
Seth Godin on standing out
10052
Talk
SD
mp4
SD
1500
[http://video.ted.com/talks/podcast/SethGodin_2003_480.mp4](http://video.ted.com/talks/podcast/SethGodin_2003_480.mp4)
In a world
Creativity
1024