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: 
Mister_DNA
Visitor

MPAA/TV ratings in videoplayer example?

First off, apologies if this has been discussed before. I searched the forums and didn't find anything, so I'm going to go ahead and ask.

Is there a way to, um, activate the MPAA/TV ratings in the videoplayer example? I'll confess... I'm a dummy about this, so I'm essentially asking if there's a line of code I can cut and paste into a .brs file.

Also, I gotta ask: is this something that *should" be done? I realize that MPAA ratings are assigned by an official organization, and since I'm currently not posting theatrical releases, I wouldn't be using the MPAA ratings. Most of my content is dry economics stuff that's suitable for all audiences, but I have a few clips with profanity and police brutality that would merit a TV-MA rating. Are TV ratings done in the same manner as MPAA ratings, or - if I were to have the ratings activated on my channel - would I be able to use my own judgement in assigning ratings?

Thanks in advance for any help, ideas, suggestions, etc.
If you want a vision of the future, imagine a boot stamping on a human face - forever. - George Orwell
0 Kudos
8 REPLIES 8
destruk
Streaming Star

Re: MPAA/TV ratings in videoplayer example?

If it's not in the xml, then it can't be displayed on the screen. For the standard videoplayer example, no ratings like that are present anywhere.
To add the ability to parse it from xml, add it to showfeed.brs

Function init_show_feed_item() As Object
o = CreateObject("roAssociativeArray")

o.ContentId = ""
o.Title = ""
o.ContentType = ""

'add rating string default value if not in XML file
o.Rating="PG-13"

o.ContentQuality = ""
o.Synopsis = ""
o.Genre = ""
o.Runtime = ""
o.StreamQualities = CreateObject("roArray", 5, true)
o.StreamBitrates = CreateObject("roArray", 5, true)
o.StreamUrls = CreateObject("roArray", 5, true)

return o
End Function

Then in parse_show_feed in the same file add a line for that

'fetch all values from the xml for the current show
item.Rating = validstr(curShow.Rating.GetText())
0 Kudos
Mister_DNA
Visitor

Re: MPAA/TV ratings in videoplayer example?

Awesome. Thanks so much for your help. I'm going to give this a go this weekend.

You mentioned something about if it's not in the xml, it's not going to show up on the screen. I understand what you're saying, 100% - a few weeks ago I experimented with changing "Synopsis" to "Description" and gained a bit of an understanding about how the .brs files look for info in the .xml files.

This raises another question for me:

If there is info in an .xml file that doesn't correspond to anything in a .brs file, will it cause any harm?

For example, I would like to add a field like this to my xml files:
<DateAdded>08-12-11</DateAdded>

Is this feasible, or would it cause problems?

Thanks again for your help!
If you want a vision of the future, imagine a boot stamping on a human face - forever. - George Orwell
0 Kudos
destruk
Streaming Star

Re: MPAA/TV ratings in videoplayer example?

No, it won't cause problems to have extra information in the xml file.
0 Kudos
Mister_DNA
Visitor

Re: MPAA/TV ratings in videoplayer example?

destruk,

I did as you suggested, with no luck. It didn't render things unplayable, but the ratings never showed up. I tried a few variations, but still no go. Here's what my showFeed.brs looks like:
Function init_show_feed_item() As Object
o = CreateObject("roAssociativeArray")

o.ContentId = ""
o.Title = ""
o.ContentType = ""
o.ContentQuality = ""
o.Synopsis = ""
o.Genre = ""
o.Runtime = ""
o.Rating = ""
o.StreamQualities = CreateObject("roArray", 5, true)
o.StreamBitrates = CreateObject("roArray", 5, true)
o.StreamUrls = CreateObject("roArray", 5, true)

return o
End Function

and here...
item = init_show_feed_item()

'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.Rating = validstr(curShow.Rating.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

and finally...
'map xml attributes into screen specific variables
item.ShortDescriptionLine1 = item.Title
item.ShortDescriptionLine2 = item.Description
item.HDPosterUrl = item.hdImg
item.SDPosterUrl = item.sdImg

item.Length = strtoi(item.Runtime)
item.Categories = CreateObject("roArray", 5, true)
item.Categories.Push(item.Genre)
item.Actors = CreateObject("roArray", 5, true)
item.Actors.Push(item.Genre)
item.Description = item.Synopsis

'add rating string default value if not in XML file
item.Rating = "TV-PG"

'Set Default screen values for items not in feed
item.HDBranded = true
item.IsHD = true
item.StarRating = "90"
item.ContentType = "episode"


What am I doing wrong? I'm pretty sure there's something wrong with my third example of code. I tried several things and nothing worked.
If you want a vision of the future, imagine a boot stamping on a human face - forever. - George Orwell
0 Kudos
destruk
Streaming Star

Re: MPAA/TV ratings in videoplayer example?

You need a <rating>PG-13</rating> in your xml file for it to show up as PG-13. Page 23 of the component reference guide lists the valid ratings you can use. I'm not sure if you can generate your own as they show up in a boldened font.

Just to see something show up, without it being in the xml, you can edit the show feed to change o.rating="" to o.rating="PG-13" or something to set the default value when no entry exists, and you might need to remove the item.rating line so it doesn't clear it out with a null value - not sure on that.
0 Kudos
Mister_DNA
Visitor

Re: MPAA/TV ratings in videoplayer example?

"destruk" wrote:
You need a <rating>PG-13</rating> in your xml file for it to show up as PG-13. Page 23 of the component reference guide lists the valid ratings you can use. I'm not sure if you can generate your own as they show up in a boldened font.

Just to see something show up, without it being in the xml, you can edit the show feed to change o.rating="" to o.rating="PG-13" or something to set the default value when no entry exists, and you might need to remove the item.rating line so it doesn't clear it out with a null value - not sure on that.


I did add a <rating></rating> tag to an xml file and tried several variations of acceptable ratings (PG-13, TV-PG, UR).

Removing the item.rating line might be worth a try, especially since it's telling the xml file to retrieve text, when the Roku wants to add an icon.

I'll keep trying, and I really appreciate your help.
If you want a vision of the future, imagine a boot stamping on a human face - forever. - George Orwell
0 Kudos
destruk
Streaming Star

Re: MPAA/TV ratings in videoplayer example?

Well, the problem is a really old one. The XML files for the shows for Ted Talks/VideoPlayer example are set to a value of "TALK" which isn't valid.
Set it to episode and you'll get your ratings.
Maybe some day they'll update the example scripts to fix mistakes like these.
Here's your channel that shows ratings:

http://hotfile.com/dl/126745271/5a984c7 ... r.zip.html

This is what I changed
in Showfeed.brs

Function init_show_feed_item() As Object
o = CreateObject("roAssociativeArray")

o.ContentId = ""
o.Title = ""
o.ContentType = ""
o.ContentQuality = ""
o.Synopsis = ""
o.Genre = ""
o.Runtime = ""
o.Rating = "PG-13" -- add this rating manually since a rating field isn't in the xml files it downloads
o.StreamQualities = CreateObject("roArray", 5, true)
o.StreamBitrates = CreateObject("roArray", 5, true)
o.StreamUrls = CreateObject("roArray", 5, true)

return o
End Function

Function parse_show_feed(xml As Object, feed As Object) As Void

showCount = 0
showList = xml.GetChildElements()

for each curShow in showList

'for now, don't process meta info about the feed size
if curShow.GetName() = "resultLength" or curShow.GetName() = "endIndex" then
goto skipitem
endif

item = init_show_feed_item()

'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()) Might as well remove this since the xml files it downloads list an invalid value of "TALK" - see page 15 of the component reference
'I left a placeholder for it if you come up with xml files later with <rating> and </rating> in them
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

'map xml attributes into screen specific variables
item.ShortDescriptionLine1 = item.Title
item.ShortDescriptionLine2 = item.Description
item.HDPosterUrl = item.hdImg
item.SDPosterUrl = item.sdImg

item.Length = strtoi(item.Runtime)
item.Categories = CreateObject("roArray", 5, true)
item.Categories.Push(item.Genre)
item.Actors = CreateObject("roArray", 5, true)
item.Actors.Push(item.Genre)
item.Description = item.Synopsis

'Set Default screen values for items not in feed
item.HDBranded = false
item.IsHD = false
item.StarRating = "90"
item.ContentType = "episode"


ContentType String ----- Valid values = movie, episode, season, series, audio. Missing attribute = NotSet


And in AppDetailScreen.brs
Function preShowDetailScreen(breadA=invalid, breadB=invalid) As Object
port=CreateObject("roMessagePort")
screen = CreateObject("roSpringboardScreen")
screen.SetDescriptionStyle("video") - A video description style will not show any set MPAA ratings. Change this to Episode (for a square SD/HDposter image) or Video (for a rectangle SD/HDposter image) and ratings display
screen.SetMessagePort(port)
if breadA<>invalid and breadB<>invalid then
screen.SetBreadcrumbText(breadA, breadB)
end if

return screen
End Function

SetDescriptionStyle(String style)
“video”: All tags except <Directors> and <Ratings> that are on the video screen above are replaced with Content Meta-Data.
0 Kudos
Mister_DNA
Visitor

Re: MPAA/TV ratings in videoplayer example?

Thank you, thank you, thank you! That worked perfectly, although I did run into another problem (more on that in a sec).

For anyone else who might be interested, here is a link to the altered showFeed.brs and appDetailScreen.brs files; all you need to do is paste them into your source folder (be sure to backup the originals). These files are a little different than the zip file destruk made available.

For starters, this doesn't default to a rating. If you don't have <rating>Acceptable rating as per SDK documentation</rating> in your xml files, no rating will show up.
Also, the appDetailScreen.brs has the following line added to it: "screen.SetStaticRatingEnabled(False)" - remove it if you want the stars to show up.
And finally, the showFeed.brs has the following lines in it:
'Set Default screen values for items not in feed
item.HDBranded = true
item.IsHD = true

What this means is that if your content is HD, you will see the "HD" icon along with the 4 dots as your video is loading. The downside: all the content is displayed on the details screen as being HD, regardless of the reolution/bitrate.

That's where I ran into a problem, albeit a very minor one. Previously, the HD icon only showed up if HD content was loading. That's still the case, but now there's an HD icon on every single video, next to the ratings. I experimented with ways of making it go away, but I couldn't do that and still have the HD icon appear when HD content was loading. It's no big deal, really. For the time being, I can live with it. If anyone else wants to use those files and doesn't want the HD icon, just change the "true" to "false".

destruk, thanks again for your help. It is greatly appreciated.
If you want a vision of the future, imagine a boot stamping on a human face - forever. - George Orwell
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.