Roku Developer Program

Developers and content creators—a complete solution for growing an audience directly.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Highlighted
Banta67
Level 7

XML - Categories/Levels Question

Hello,

I am trying to develop a channel based on the VIDEOPLAYER Sample.

Currently, in the sample categories.xml, each category has <categoryLeaf> nodes, as such.....

<category title="Technology" description="TED Talks on Technology" sd_img="http://rokudev.roku.com/rokudev/examples/videoplayer/images/TED_Technology.png" hd_img="http://rokudev.roku.com/rokudev/examples/videoplayer/images/TED_Technology.png">
<categoryLeaf title="The Mind" description="" feed="http://rokudev.roku.com/rokudev/examples/videoplayer/xml/themind.xml"/>
<categoryLeaf title="Global Issues" description="" feed="http://rokudev.roku.com/rokudev/examples/videoplayer/xml/globalissues.xml" />
</category>


My question is regarding categories that don't need leafs. How could I just select a category and go directly to the associated feed without the need to select a leaf?

Would this work?

<category title="Technology" description="TED Talks on Technology" sd_img="http://rokudev.roku.com/rokudev/examples/videoplayer/images/TED_Technology.png" hd_img="http://rokudev.roku.com/rokudev/examples/videoplayer/images/TED_Technology.png" feed="http://rokudev.roku.com/rokudev/examples/videoplayer/xml/themind.xml"/>
<category title="Entertainment" description="TED Talks on Entertainment" sd_img="http://rokudev.roku.com/rokudev/examples/videoplayer/images/TED_Entertainment.png" hd_img="http://rokudev.roku.com/rokudev/examples/videoplayer/images/TED_Entertainment.png">
<categoryLeaf title="Music" description="" feed="http://rokudev.roku.com/rokudev/examples/videoplayer/xml/music.xml" />
<categoryLeaf title="Inspiration" description="" feed="http://rokudev.roku.com/rokudev/examples/videoplayer/xml/inspiration.xml" />
</category>


In the case above, the FEED attribute is moved out of the <categoryLeaf> node and placed in the parent <category> node. If the user selects Technology, they are taken directly to the themind.xml feed. However if they selected Entertainment, they would have to choose a leaf to further drill down.
Make sense? Would this work? If not, can you explain what it would entail to make this work?

Thank you for your help.
Banta
0 Kudos
40 Replies
RokuKevin
Level 9

Re: XML - Categories/Levels Question

For a feed of the size in the videoplayer sample app, it would probably make sense to have just one .xml file that contained all the nodes for every category. The sample is broken up into several different feeds because we feel it would be a good "best practice" to break up your feeds into more manageable chunks. Very large feeds are expensive to download, take up a lot of memory on the box and take a long time to parse. That's why we encourage breaking up your feeds.

That said, you can always change the way the sample app is parsing the feeds if you want to combine them into one feed for you application. Just change the feed parsing code in categoryFeed.brs and showFeed.brs

--Kevin
0 Kudos
cgerrish
Level 7

Re: XML - Categories/Levels Question

Did you figure out how to skip the category leaf section for certain categories and go straight to the feed? If so any hints you would like to share would be awesome.
0 Kudos
joetesta
Level 10

Re: XML - Categories/Levels Question

I'm also trying to figure out how to eliminate the "leafs" (or at least the extra down click required to go from the leaf name to the list of shows)

Just change the feed parsing code in categoryFeed.brs and showFeed.brs


he makes it sound so easy Smiley Happy I'm looking at that code now, scratching my head... well I broke everything - starting over with fresh example source for round 2...

maybe it will be easier to have just 1 category and use the leafs as my categories, then the user would only have to do the extra click in the beginning.
aspiring
0 Kudos
joetesta
Level 10

Re: XML - Categories/Levels Question


Traversing: 17ms
showHomeScreen | msg = | index = 1
showHomeScreen | msg = | index = 1
device already linked, skipping registration process
list item selected | index = 1
invalid parameter of type roInvalid for <ROT:roInvalid> is not roAssociativeArra
y in function initShowFeedConnection
Current Function:
125: Function getShowsForCategoryItem(category As Object, item As Integer) As Ob
ject
126:
127: if validateParam(category, "roAssociativeArray", "getCategoryList") = f
alse return invalid
128:
129: conn = InitShowFeedConnection(category.kids[item])
130: 'conn = InitShowFeedConnection(category)
131: showList = conn.LoadShowFeed(conn)
132: return showList
133:
134: End Function
/tmp/plugin/HHAAAAgTifHi/pkg:/source/appPosterScreen.brs(131): runtime error f4:
Member function not found in BrightScript Component or interface.

131: showList = conn.LoadShowFeed(conn)

Backtrace:
Function getshowsforcategoryitem(category As Object, item As Integer) As Object
Function showposterscreen(screen As Object, category As Object) As Integer
Function displaycategoryposterscreen(category As Object) As Untyped
Function showhomescreen(screen As Untyped) As Integer
Function main() As Void

Local Variables:
category &h16 bsc:roAssociativeArray, refcnt=5
item &h02 Integer val:0
global &h07 rotINTERFACE:ifGlobal
m &h06 bsc:roAssociativeArray, refcnt=6
conn &h16 bsc:roInvalid, refcnt=1
showlist &h30 Untyped val:Uninitialized
BrightScript Debugger> ------ Running ------
Looking for conn: http://192.168.1.224/categories.xml
created feed connection for http://192.168.1.224/categories.xml
url: http://192.168.1.224/categories.xml
Took: 28ms
Parse Took: 3ms
begin category node parsing
number of categories: 4
ParseCategoryNode: banner_ad
ParseCategoryNode skip: banner_ad
parse returned no child node
ParseCategoryNode: category
category: Newly Added | Movies that have been recently added
added new child node
ParseCategoryNode: category
category: Big News | Movies that feature news
added new child node
ParseCategoryNode: category
category: College | Movies about what it's like to go to college
added new child node
Traversing: 23ms
showHomeScreen | msg = | index = 1
showHomeScreen | msg = | index = 1
device already linked, skipping registration process
list item selected | index = 1
invalid parameter of type roInvalid for <ROT:roInvalid> is not roAssociativeArra
y in function initShowFeedConnection
BrightScript Micro Debugger.
Enter any BrightScript statement, debug commands, or HELP.

Current Function:
125: Function getShowsForCategoryItem(category As Object, item As Integer) As Ob
ject
126:
127: if validateParam(category, "roAssociativeArray", "getCategoryList") = f
alse return invalid
128:
129: conn = InitShowFeedConnection(category.kids[item])
130: 'conn = InitShowFeedConnection(category)
131: showList = conn.LoadShowFeed(conn)
132: return showList
133:
134: End Function
/tmp/plugin/JHAAAAhHGxgy/pkg:/source/appPosterScreen.brs(131): runtime error f4:
Member function not found in BrightScript Component or interface.

131: showList = conn.LoadShowFeed(conn)

Backtrace:
Function getshowsforcategoryitem(category As Object, item As Integer) As Object
Function showposterscreen(screen As Object, category As Object) As Integer
Function displaycategoryposterscreen(category As Object) As Untyped
Function showhomescreen(screen As Untyped) As Integer
Function main() As Void

Local Variables:
category &h16 bsc:roAssociativeArray, refcnt=5
item &h02 Integer val:0
global &h07 rotINTERFACE:ifGlobal
m &h06 bsc:roAssociativeArray, refcnt=6
conn &h16 bsc:roInvalid, refcnt=1
showlist &h30 Untyped val:Uninitialized
BrightScript Debugger>
aspiring
0 Kudos

Re: XML - Categories/Levels Question

I can tell you from experience, that my first ever time coding with brightscript or really anything other than PHP :roll: , that you picked the hardest example to tackle your first time around.

is it that you just don't like the function of click down? or do you only have one category?

you don't need to use the category leafs if you don't want anyways. show us what your xml looks like, maybe one of us can help you out
Twitter: iptvmyway facebook: iptvmyay
Channels: Warriors of War, Go Fight Live, Heading Outdoorz, IPTVmyway
0 Kudos
joetesta
Level 10

Re: XML - Categories/Levels Question

thanks dynamitemedia!

I got it to work! My last change was adding this line 'o.Feed = xml@feed' in CategoryFeed.brs to Function ParseCategoryNode just before this line 'elseif xml.GetName() = "categoryLeaf" then'

is it that you just don't like the function of click down? or do you only have one category?
you don't need to use the category leafs if you don't want anyways.


We have multiple categories, but not subcategories (leafs). Those subcategories are overkill for what we have, and going with a single subcategory in each category seemed pointless, because then the user has to click an extra time to start scrolling through the options. Maybe I will reconsider that.

Figuring out how to eliminate the subcategories took me about 4 hours of following the functions/ subroutines from file to file and adding debug code to see what was happening along the way. I don't feel any smarter but maybe my next task will go easier, after having survived this challenge.
aspiring
0 Kudos

Re: XML - Categories/Levels Question

i see what your saying, yes the video player is tough, its like the complete package but missing the essentials to make it work for a newbie, i know i went thru it.

to make it worse is that its spread out so many pages and not sure what connects to what in the flow at first, but once you do its gets easier.
Twitter: iptvmyway facebook: iptvmyay
Channels: Warriors of War, Go Fight Live, Heading Outdoorz, IPTVmyway
0 Kudos
ChrisDotson
Level 7

Re: XML - Categories/Levels Question

"joetesta" wrote:
I got it to work! My last change was adding this line 'o.Feed = xml@feed' in CategoryFeed.brs to Function ParseCategoryNode just before this line 'elseif xml.GetName() = "categoryLeaf" then'


Any chance you would share all of the changes you made? I'm trying to do the exact same thing and having the worst time getting it to work.
0 Kudos
joetesta
Level 10

Re: XML - Categories/Levels Question

Wow apologies for the extremely late reply, I've been on another project for months and just came back to look at roku again this week.

Well here goes, I hope you've figured it out by now but maybe this will help someone else!

in appDetailSceen.brs Replace:
Function preShowDetailScreen(breadA=invalid, breadB=invalid) As Object
port=CreateObject("roMessagePort")
screen = CreateObject("roSpringboardScreen")
screen.SetDescriptionStyle("video")
screen.SetMessagePort(port)
if breadA<>invalid and breadB<>invalid then
screen.SetBreadcrumbText(breadA, breadB)
end if

with
Function preShowDetailScreen(breadA=invalid) As Object
port=CreateObject("roMessagePort")
screen = CreateObject("roSpringboardScreen")
screen.SetDescriptionStyle("video")
screen.SetMessagePort(port)


in appPosterScreen.brs change
    screen = preShowDetailScreen(category.Title, category.kids[m.curCategory].Title)
showIndex = showDetailScreen(screen, shows, showIndex)

to
    'screen = preShowDetailScreen(category.Title, category.kids[m.curCategory].Title)
screen = preShowDetailScreen(category.Title)
showIndex = showDetailScreen(screen, shows, showIndex)


and also in appPosterScreen.brs change this
    categoryList = CreateObject("roArray", 100, true)
for each subCategory in topCategory.Kids
categoryList.Push(subcategory.Title)
next
return categoryList

to this
    categoryList = CreateObject("roArray", 100, true)
categoryList = topCategory

return categoryList


and also in appPosterScreen.brs change this
    conn = InitShowFeedConnection(category.kids[item])

to this
    conn = InitShowFeedConnection(category)


and in CategoryFeed.brs
        o.HDPosterURL = xml@hd_img

to this
        o.HDPosterURL = xml@hd_img
o.Feed = xml@feed


and also in CategoryFeed.brs change this
           kid.HDPosterURL = xml@hd_img
o.AddKid(kid)

to
            kid.HDPosterURL = xml@hd_img
kid.Feed = e@feed
o.AddKid(kid)


I *think* that's it, I apologize if anything is extraneous or incorrect, it's been a while!!
aspiring
0 Kudos