Roku Developer Program

Join our online forum to talk to Roku developers and fellow channel creators. Ask questions, share tips with the community, and find helpful resources.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
axiomy
Visitor

mrss_grid_template.1.0.1 multi playback issue MP4 and HLS

I am doing some testing on the mrss_grid_template.1.0.1 and I would like to be able to play either MP4 or HLS Video. So far I have only gotten it to do one or the other by changing the code in the NWM_MRSS.brs

	xml = CreateObject("roXMLElement")
if xml.Parse(raw)
for each item in xml.channel.item
newItem = {
guid: ValidStr(item.guid.GetText())
streams: []
streamFormat: "mp4"
minBandwidth: 250
'maxBandwidth: 2200
actors: []
categories: []
contentType: "episode"
bookmarkPosition: 0
}

' title
tmp = item.GetNamedElements("media:title")
if tmp.Count() > 0
newItem.title = util.HTMLEntityDecode(ValidStr(tmp[0].GetText()))
newItem.shortDescriptionLine1 = util.HTMLEntityDecode(ValidStr(tmp[0].GetText()))
else
newItem.title = util.HTMLEntityDecode(ValidStr(item.title.GetText()))
newItem.shortDescriptionLine1 = util.HTMLEntityDecode(ValidStr(item.title.GetText()))
end if




if I change "streamFormat: "mp4" to streamFormat: "hls" then it does play hls fine but it disables MP4 playback. All attempts have failed to get it to play both, How would I allow the HLS playback without disabling the MP4 playback?

Any advice would be greatly appreciated.
0 Kudos
8 REPLIES 8
RokuChris
Roku Employee
Roku Employee

Re: mrss_grid_template.1.0.1 multi playback issue MP4 and HL

That's not directly supported by the template, but fairly easy to do by setting streamFormat on a per-item basis. You'd need to modify the parsing logic to look for the type attribute on the media:content element for each piece of content. Its value will be the MIME type of that content, so set streamFormat appropriately for each item based on that value.

http://www.rssboard.org/media-rss#media-content
0 Kudos
axiomy
Visitor

Re: mrss_grid_template.1.0.1 multi playback issue MP4 and HL

That was one of the first things I tried in the rss feed. I will review your link and information tomorrow and try again. I will report my findings Anyone else have advice please help. Thank you for responding hopefully we can get a dialog going and solve this. 🙂
0 Kudos
axiomy
Visitor

Re: mrss_grid_template.1.0.1 multi playback issue MP4 and HL

You are correct. I still haven't solved it but I see that I'm not parsing logic to look for the "type" attribute on the media:content element for each piece of content. So when I had tried to set the content type in the rss it was unaware to look for type. I am going to attempt to correct that now. What I don't understand is it seems to be parsing the "media:content" and I thought the attributes where already part of it. When I I put in the type="video/mp4" or type="video/hls" it still only plays one or the other depending on what the guid:streamFormat is set two. I am assuming I will need to add code to the "media:content" section to correctly parse the type="video/hls" tag?

	
' media:content can be a child of <item> or of <media:group>
contentItems = item.GetNamedElements("media:content")
if contentItems.Count() = 0
tmp = item.GetNamedElements("media:group")
if tmp.Count() > 0
contentItems = tmp.GetNamedElements("media:content")
end if
end if

' length
tmp = item.GetNamedElements("blip:runtime")
if tmp.Count() > 0
length = StrToI(ValidStr(tmp[0].GetText()))
if length > 0
newItem.length = length
end if
end if

if contentItems.Count() > 0
for each content in contentItems
if ValidStr(content@url) <> ""
newStream = {
url: ValidStr(content@url)
bitrate: StrToI(ValidStr(content@bitrate))
contentID: contentIDPrefix + "|" + newItem.title
}

' use the content's height attribute to determine HD-ness
if StrToI(ValidStr(content@height)) > 720
newStream.quality = true
newItem.HDBranded = true
newItem.isHD = true
newItem.fullHD = true
else if StrToI(ValidStr(content@height)) > 480
newStream.quality = true
newItem.HDBranded = true
newItem.isHD = true
end if

newItem.streams.push(newStream)
end if
next

length = StrToI(ValidStr(contentItems[0]@duration))
if newItem.length = invalid and length > 0
newItem.length = length
end if
0 Kudos
RokuChris
Roku Employee
Roku Employee

Re: mrss_grid_template.1.0.1 multi playback issue MP4 and HL

"axiomy" wrote:
I am assuming I will need to add code to the "media:content" section to correctly parse the type="video/hls" tag?


Correct. Also note that video/hls is not a valid MIME type. HLS streams are usually indicated by application/x-mpegURL or application/vnd.apple.mpegURL

http://tools.ietf.org/html/draft-pantos ... reaming-13
https://developer.apple.com/library/ios ... 32-CH2-SW3
0 Kudos
axiomy
Visitor

Re: mrss_grid_template.1.0.1 multi playback issue MP4 and HL

Thanks Chris I will take a look now and see what I can do. I will report back the progress.
0 Kudos
axiomy
Visitor

Re: mrss_grid_template.1.0.1 multi playback issue MP4 and HL

Is it possible to put in in the enclosure? as something like this
   if item.enclosure@type = "application/x-mpegURL" or LCase (Right (url, 4)) = ".M3U8"
newItem.streamFormat = "hls"
else if item.enclosure@type = "video/MP2T" or LCase (Right (url, 4)) = ".ts"
newItem.streamFormat = "hls"
0 Kudos
RokuChris
Roku Employee
Roku Employee

Re: mrss_grid_template.1.0.1 multi playback issue MP4 and HL

That would work if the feeds you're parsing are RSS with enclosures as opposed to MRSS.

http://cyber.law.harvard.edu/rss/rss.ht ... OfLtitemgt

I doubt that you'd ever come across a link to a TS file in a feed.
0 Kudos
axiomy
Visitor

Re: mrss_grid_template.1.0.1 multi playback issue MP4 and HL

ok so I added this to the end of the NWM_MRSS.brs
  ' we didn't find any media:content tags, try the enclosure tag
url = ValidStr(item.enclosure@url)
if item.enclosure@type = "application/x-mpegURL" or LCase (Right (url, 4)) = ".m3u8"
newItem.streamFormat = "hls"

else if item.enclosure@type = "audio/mpeg" or LCase (Right (url, 4)) = ".mp3"
newItem.streamFormat = "mp3"

newItem.url = url
else
newStream = {
url: ValidStr(item.enclosure@url)
}

newItem.streams.Push(newStream)
endif

'PrintAA(newItem)
result.Push(newItem)
end if
next
end if

return result
end function
right above the code I added so it would play mp3 audio and shoutcast. The Audio plays fine but the hls will not load.


At the beginning of the .brs the default is set to MP4
 guid:             ValidStr(item.guid.GetText())
streams: []
streamFormat: "mp4"
minBandwidth: 880
'maxBandwidth: 2200
actors: []
categories: []
contentType: "episode"
bookmarkPosition: 0


The test feed is itunes rss and failed to play with with an enclosure url "" type="video/hls"/> and locked up on playblack when type="application/x-mpegURL" If I change the guid to hls it plays no problem but then disables all mp4 playback. What am I doing wrong here?
0 Kudos
Need Assistance?
Welcome to the Roku Community! Feel free to search our Community for answers or post your question to get help.

Become a Roku Streaming Expert!

Share your expertise, help fellow streamers, and unlock exclusive rewards as part of the Roku Community. Learn more.