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

Content Meta-Data ContenType int or string

ContenType

The docs says it's a string but it returns an int. Is there a nice way to map these values?


   testContent = CreateObject("RoSGNode", "ContentNode")
   testcontent.ContentType = "movie"
   print "testContent.ContenType " ; testContent.ContentType
   'result: testContent.ContenType 1


So when I do:


   if  testContent.ContentType = "movie"
       print "Worked"
   else
       print "didn't work"
   end if


It doesn't compare properly. I'm guessing it's an Enum of sorts?
Like:

   { 
        "NotSet"  :  0, 
        "movie"   :  1,
        "series" :  2,
        "season"  :  3,
        "episode" :  4,
        "audio"   :  5 
    }


If so, can we access it by name somehow?
0 Kudos
5 REPLIES 5
level32
Visitor

Re: Content Meta-Data ContenType int or string

I had to resort to making my own array. If someone knows a better solution, please let me know.


Function Const() As Object

this = m.instance

if this = invalid
this = CreateObject("roAssociativeArray")
this.ContentType = {
"NOTSET" : 0,
"MOVIE" : 1,
"SERIES" : 2,
"SEASON" : 3,
"EPISODE" : 4,
"AUDIO" : 5
}

this.ContentTypeName = [
"NOTSET",
"MOVIE",
"SERIES",
"SEASON",
"EPISODE",
"AUDIO"
]

m.instance = this

end if

return this
End Function


Then I call it like this:


testContent = CreateObject("RoSGNode", "ContentNode")
testcontent.ContentType = "movie"
print "testContent.ContenType " ; Const().ContentTypeName[testContent.ContentType]
'result: testContent.ContenType MOVIE
0 Kudos
EnTerr
Roku Guru

Re: Content Meta-Data ContenType int or string

Clearly a bug, it seems! If it's a string-in, should be string-out. (under extended GIGO doctrine :mrgreen: )

Someone @Roku should respond.
Be prepared that when/if they fix it, it will suddenly start returning strings and your current code stop working.

Btw, equivalent but easier and faster would be doing `this = { }` instead of `this = CreateObject("roAssociativeArray")`
0 Kudos
level32
Visitor

Re: Content Meta-Data ContenType int or string

I have other things in my Const class, hence the roAssociativeArray.
I'm actually going to use a custom contentType to avoid future problems.


<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE xml>

<component name="MovieGridItemData" extends="ContentNode">
<interface>
<field id="itemType" type="integer" />
</interface>
</component>
0 Kudos
EnTerr
Roku Guru

Re: Content Meta-Data ContenType int or string

"level32" wrote:
I have other things in my Const class, hence the roAssociativeArray.

BrightScript Debugger> ? type({})
roAssociativeArray
0 Kudos
level32
Visitor

Re: Content Meta-Data ContenType int or string

Oh... I see what you mean... Thanks
0 Kudos