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?

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

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")

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>

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

BrightScript Debugger> ? type({})
roAssociativeArray

Oh… I see what you mean… Thanks