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

Processing XML sub-categories

I am trying to see the best to way to display and process sub-categories in my xml
for eg, I have an xml something like the following.

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<categories>
<category title="Browse Movies" description="Browse Movies" sd_img="movie.png" hd_img="movies.png">
<categorysub title="Movie Genres" description="Movie Genres" sd_img="movie_genre.png" hd_img="movie_genre.png">
<categoryLeaf title="Action" description="" feed="Action.xml"/>
<categoryLeaf title="Drama" description="" feed="drama.xml" />
</categorysub>
<categorysub title="Movies By Collection" description="Movies By Collection" sd_img="movie_collection.png" hd_img="movie_collection.png">
<categoryLeaf title="Disney" description="" feed="Disney.xml"/>
<categoryLeaf title="Imax" description="" feed="Imax.xml" />
</categorysub>
</category>
</categories>

Process flow would be :
Browse Movies ( Home screen - roPosterScreen) --> Movie Genres(roPosterScreen) ---> Action , Drama (roPosterScreen) ---> feed (roSpringBoardScreen )

Would like to see how I can modify the video player example to achieve this.

Thanks for any pointers.
0 Kudos
7 REPLIES 7
RokuKevin
Visitor

Re: Processing XML sub-categories

There are several approaches to this... I would think the quickest way is to leverage the current structure of the videoplayer app.

Following the structure of the videoplayer example, you may want to break up the subcategories into its own xml file. You could then copy categoryFeed.brs to subCategoryFeed.brs and modify both so that you can parse the new level of categories. I'd also use preShowHomeScreen() and showHomeScreen() as templates for preShowSubCategory() and showCategoryScreen() methods.

Hope this gets you started...

--Kevin
0 Kudos
jandre
Visitor

Re: Processing XML sub-categories

Thanks Kevin!

So do you mean something like the following.

categories.xml

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<categories>
<category title="Browse Movies" description="Browse Movies" sd_img="movie.png" hd_img="movies.png">
<categoryLeaf title="Browse movies" description="" feed="subcategory.xml" />
</category>
</categories>

subcategory.xml

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<categories>
<category title="Movie Genres" description="Movie Genres" sd_img="movie_genre.png" hd_img="movie_genre.png">
<categoryLeaf title="Action" description="" feed="Action.xml"/>
<categoryLeaf title="Drama" description="" feed="drama.xml" />
</category>
<category title="Movies By Collection" description="Movies By Collection" sd_img="movie_collection.png" hd_img="movie_collection.png">
<categoryLeaf title="Disney" description="" feed="Disney.xml"/>
<categoryLeaf title="Imax" description="" feed="Imax.xml" />
</category>
</categories>

also can we initialize both category and subCategory screens in AppMain.brs something like this?

Sub Main()

'initialize theme attributes like titles, logos and overhang color
initTheme()

'prepare the screen for display and get ready to begin
screen=preShowHomeScreen("", "")
subscreen=preShowSubCategory("", "")
if screen=invalid then
print "unexpected error in preShowHomeScreen"
return
end if
'set to go, time to get started
showHomeScreen(screen)
showCategoryScreen(subscreen)

End Sub

Also initialize subcategories.xml in InitSubCategoryFeedConnection() of subCategoryFeed.brs

Function InitSubCategoryFeedConnection() As Object

conn = CreateObject("roAssociativeArray")

conn.UrlPrefix = "http://test.com/roku/videoplayer/xml"
conn.UrlCategoryFeed = conn.UrlPrefix + "/subcategories.xml"

conn.Timer = CreateObject("roTimespan")

conn.LoadCategoryFeed = load_sub_category_feed
conn.GetCategoryNames = get_sub_category_names

print "created feed connection for " + conn.UrlCategoryFeed
return conn

End Function

Let me know if I am on the right track?
0 Kudos
RokuKevin
Visitor

Re: Processing XML sub-categories

You started out on the right track by separating the .xml files. But I was expecting you to modify the code in showHomeScreen() and change the calls:

if kid.type = "special_category" then
displaySpecialCategoryScreen()
else
displayCategoryPosterScreen(kid)
end if


to

 
displaySubCategoryScreen()


where displaySubCategoryScreen() is defined in your newly created subCategoryFeed.brs.

--Kevin
0 Kudos
saravanainfo
Visitor

Re: Processing XML sub-categories

Hello all.. i am new to all this... need a help with an issue that i am facing...

I used the existing example code from the sdk "Videoplayer" and tried to change the url, xml, etc.

i am facing problem with this brs file named "CategoryFeed".

There is a code "conn.UrlPrefix = "http://rokudev.roku.com/rokudev/examples/videoplayer/xml"...
how do I change this part to my xml folder? i tried this following, it didn't work as I expected. can you give me a suggestion?

conn.UrlPrefix = "pkg:/XML"

As i told you, i didn't expect this to work, but need a work around to make it work. please help
0 Kudos
luke823
Visitor

Re: Processing XML sub-categories

is this still the most current information on sub-categories, or can it be done now without having to write bright script?
0 Kudos
b14d3
Visitor

Re: Processing XML sub-categories

"saravanainfo" wrote:

conn.UrlPrefix = "pkg:/XML"


The xml should be in an internet-accessible URL, not contained in the package. http://rokudev.roku.com you can put in a browser and get to it, so follow that as an example and you'll be right as rain.
0 Kudos
Blackhawk
Roku Guru

Re: Processing XML sub-categories

Like this?

conn.UrlPrefix   = "rokudev.roku.com/Channel/xml/shows"

    conn.UrlCategoryFeed = conn.UrlPrefix + "/Shows.xml"
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.