video player example

I am trying to add an about us category using roparagraph on the main screen. Can some one point me in the correct direction? I am using the video player example.

thanks.

You could edit the categories.xml (used on your own website point downloads to your site) to add the “About Us” category.

Then edit the appHomeScreen.brs file and find this code:


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

Replace it with your own code to check for the “About Us” category and display your poster screen.

–Kevin

thanks kevin. i am having some trouble with the code.

here is what i modified in my apphomescreen.brs. thanks in advance

kid = m.Categories.Kids[msg.GetIndex()]
if kid.type = “About Us” then
ShowParagraphScreen()
else
displayCategoryPosterScreen(kid)
end if

i also called this function
Function ShowParagraphScreen() As Void
port = CreateObject(“roMessagePort”)
screen = CreateObject(“roParagraphScreen”)
screen.SetMessagePort(port)
screen.SetTitle(“[Screen Title]”)
screen.AddHeaderText(“[Header Text]”)
screen.AddParagraph(“[Paragraph text 1 - Text in the paragraph screen is justified to the right and left edges]”)
screen.AddParagraph(“[Paragraph text 2 - Multiple paragraphs may be added to the screen by simply making additional calls]”)
screen.AddButton(1, “[button text 1]”)
screen.AddButton(2, “[button text 2]”)
screen.Show()
while true
msg = wait(0, screen.GetMessagePort())
if type(msg) = " roParagraphScreenEvent"
exit while
endif
end while
End Function

here is what i am getting in the debugger.

Current Function:
118: Function getShowsForCategoryItem(category As Object, item As Integer) As Object
119:
120: if validateParam(category, “roAssociativeArray”, “getCategoryList”) = false return invalid
121:
122: conn = InitShowFeedConnection(category.kids[item])
123: showList = conn.LoadShowFeed(conn)
124: return showList
125:
126: End Function
/tmp/plugin/PFAAAAFOtmFL/pkg:/source/appPosterScreen.brs(123): runtime error f4: Member function not found in BrightScript Component or interface.

123: 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>

this issue has been resolve. thanks.

Cool! what was the crux of the issue?

i removed the about us category from the xml file. added a poster on the homescreen and linked it to paragraph code.

in the apphomescreen.brs


Function initCategoryList() As Void

    conn = InitCategoryFeedConnection()

    m.Categories = conn.LoadCategoryFeed(conn)
    m.Categories.Kids.Push({ Type: "About Us", ShortDescriptionLine1: "About Us",      ShortDescriptionLine2: "Learn More about ", HDPosterUrl: "pkg:/images/hd-aboutus.png", SDPosterUrl: "pkg:/images/sd-aboutus.png" })
    m.CategoryNames = conn.GetCategoryNames(m.Categories)
        
End Function

in the apphomescreen.brs

	if kid.type = "About Us" then
                    'print "About Us"
                    aboutUs = ShowParagraphScreen()
        
		else if kid.type = "special_category" then
                    displaySpecialCategoryScreen()

i created an aboutus.brs which contained the paragraph functions

one issue i just noticed is that the loop is broken after selecting the about us. i have to exit the app and reload return functionality.

just fixed the loop. changed this line in my about us.brs.

     while true
        msg = wait(0, screen.GetMessagePort())

	print "got message"

        if type(msg) = "roParagraphScreenEvent"
            if msg.isScreenClosed()
                print "Screen closed"
                exit while                
            else if msg.isButtonPressed()
                print "Button pressed: "; msg.GetIndex(); " " msg.GetData()
                exit while
            else
                print "Unknown event: "; msg.GetType(); " msg: "; msg.GetMessage()
                exit while
            endif
        endif
    end while

I am attempting the same thing using the videoplayer example. I have one category that pulls a feed from my xml file, but I am trying to setup an About Us page with a few lines of text, header, etc. I have used some of the code above to get to the point where it gives me another poster image on my home screen, but it won’t go to my “About Us” page.

I think it may be something wrong with the aboutUs.brs file that I created. Here is what I am getting from the Brightscript Debugger:

created feed connection for http://selectbroadcasting.org/roku/examples/source/
RBS/xml/categories.xml
url: http://selectbroadcasting.org/roku/examples/source/SRBS/xml/categories.xml
Took: 197ms
Parse Took: 0ms
begin category node parsing
number of categories: 1
ParseCategoryNode: category
category: Recent Episodes | Watch Recent Episodes
categoryLeaf: Time for Hope TV Episodes []
ParseCategoryNode: categoryLeaf
added new child node
Traversing: 0ms
showHomeScreen | msg =  | index =  0
showHomeScreen | msg =  | index =  1
showHomeScreen | msg =  | index =  1
list item selected | index =  1
Current Function:
035: Function showHomeScreen(screen) As Integer
036:
037:     if validateParam(screen, "roPosterScreen", "showHomeScreen") = false r
turn -1
038:
039:     initCategoryList()
040:     screen.SetContentList(m.Categories.Kids)
041:     screen.SetFocusedListItem(3)
042:     screen.Show()
043:
044:     while true
045:         msg = wait(0, screen.GetMessagePort())
046:         if type(msg) = "roPosterScreenEvent" then
047:             print "showHomeScreen | msg = "; msg.GetMessage() " | index =
; msg.GetIndex()
048:             if msg.isListFocused() then
049:                 print "list focused | index = "; msg.GetIndex(); " | categ
ry = "; m.curCategory
050:             else if msg.isListItemSelected() then
051:                 print "list item selected | index = "; msg.GetIndex()
052:                 kid = m.Categories.Kids[msg.GetIndex()]
053:                 if kid.type = "About Us" then
054:                     'print "About Us"
055:                     aboutUs = ShowParagraphScreen()
056:       else if kid.type = "special_category" then
057:                     displaySpecialCategoryScreen()
058:                 else
059:                     displayCategoryPosterScreen(kid)
060:                 end if
061:             else if msg.isScreenClosed() then
062:                 return -1
063:             end if
064:         end If
065:     end while
066:
067:     return 0
068:
069: End Function
Wrong number of function parameters. (runtime error &hf1) in ...pkg:/source/app
omeScreen.brs(55)

055:                     aboutUs = ShowParagraphScreen()
Backtrace:
Function showhomescreen(screen As ) As Integer
   file/line: /tmp/plugin/PEAAAAgwIL...pkg:/source/appHomeScreen.brs(55)
Function main() As
   file/line: /tmp/plugin/PEAAAAgwILaT/pkg:/source/appMain.brs(20)

Local Variables:
screen   &h0010 bsc:roPosterScreen, refcnt=2
global   &h0020 rotINTERFACE:ifGlobal
m        &h0010 bsc:roAssociativeArray, refcnt=3
msg      &h0010 bsc:roPosterScreenEvent, refcnt=1
kid      &h4010 bsc:roAssociativeArray, refcnt=2
aboutus  &h0000 <uninitialized> val:Uninitialized

My About Us page code is like this:

Function showParagraphScreen(screen) As Integer

	' borrow some pictures from the monitor setup program
    	host = "http://rokudev.roku.com/rokudev/testpatterns/"

	screen.SetTitle("Title Text")
    	screen.AddHeaderText("Header Text")
        screen.AddParagraph("Paragraph Text")

    	adUrl = host + "1280x720" + "/SMPTE_bars_setup_labels_lg.jpg"
	print "adUrl=" + adUrl
	screen.AddGraphic(adURL,"scale-to-fit")

	screen.AddButton(1,"Close")
	screen.Show()

    while true
        msg = wait(0, screen.GetMessagePort())

	print "got message"

        if type(msg) = "roParagraphScreenEvent"
            if msg.isScreenClosed()
                print "Screen closed"
                exit while                
            else if msg.isButtonPressed()
                print "Button pressed: "; msg.GetIndex(); " " msg.GetData()
                exit while
            else
                print "Unknown event: "; msg.GetType(); " msg: "; msg.GetMessage()
                exit while
            endif
        endif
    end while

End Function

Here is the complete code for my appHomeScreen.brs:

Function preShowHomeScreen(breadA=invalid, breadB=invalid) As Object

    if validateParam(breadA, "roString", "preShowHomeScreen", true) = false return -1
    if validateParam(breadA, "roString", "preShowHomeScreen", true) = false return -1

    port=CreateObject("roMessagePort")
    screen = CreateObject("roPosterScreen")
    screen.SetMessagePort(port)
    if breadA<>invalid and breadB<>invalid then
        screen.SetBreadcrumbText(breadA, breadB)
    end if

    screen.SetListStyle("flat-category")
    screen.setAdDisplayMode("scale-to-fit")
    return screen

End Function

'******************************************************
'** Display the home screen and wait for events from 
'** the screen. The screen will show retreiving while
'** we fetch and parse the feeds for the game posters
'******************************************************
Function showHomeScreen(screen) As Integer

    if validateParam(screen, "roPosterScreen", "showHomeScreen") = false return -1

    initCategoryList()
    screen.SetContentList(m.Categories.Kids)
    screen.SetFocusedListItem(3)
    screen.Show()

    while true
        msg = wait(0, screen.GetMessagePort())
        if type(msg) = "roPosterScreenEvent" then
            print "showHomeScreen | msg = "; msg.GetMessage() " | index = "; msg.GetIndex()
            if msg.isListFocused() then
                print "list focused | index = "; msg.GetIndex(); " | category = "; m.curCategory
            else if msg.isListItemSelected() then
                print "list item selected | index = "; msg.GetIndex()
                kid = m.Categories.Kids[msg.GetIndex()]
                if kid.type = "About Us" then
                    'print "About Us"
                    aboutUs = displayParagraphScreen()     
      else if kid.type = "special_category" then
                    displaySpecialCategoryScreen()
                else
                    displayCategoryPosterScreen(kid)
                end if
            else if msg.isScreenClosed() then
                return -1
            end if
        end If
    end while

    return 0

End Function

'**********************************************************
'** When a poster on the home screen is selected, we call
'** this function passing an associative array with the 
'** data for the selected show.  This data should be 
'** sufficient for the show detail (springboard) to display
'**********************************************************
Function displayCategoryPosterScreen(category As Object) As Dynamic

    if validateParam(category, "roAssociativeArray", "displayCategoryPosterScreen") = false return -1
    screen = preShowPosterScreen(category.Title, "")
    showPosterScreen(screen, category)

    return 0
End Function

'**********************************************************
'** Special categories can be used to have categories that
'** don't correspond to the content hierarchy, but are
'** managed from the server by data from the feed.  In these
'** cases we might show a different type of screen other
'** than a poster screen of content. For example, a special
'** category could be search, music, options or similar.
'**********************************************************
Function displaySpecialCategoryScreen() As Dynamic

    ' do nothing, this is intended to just show how
    ' you might add a special category ionto the feed

    return 0
End Function

'************************************************************
'** initialize the category tree.  We fetch a category list
'** from the server, parse it into a hierarchy of nodes and
'** then use this to build the home screen and pass to child
'** screen in the heirarchy. Each node terminates at a list
'** of content for the sub-category describing individual videos
'************************************************************
Function initCategoryList() As Void

    conn = InitCategoryFeedConnection()

    m.Categories = conn.LoadCategoryFeed(conn)
    m.Categories.Kids.Push({ Type: "About Us", ShortDescriptionLine1: "About Us",      ShortDescriptionLine2: "Learn More about ", HDPosterUrl: "pkg:/images/hd-aboutus.png", SDPosterUrl: "pkg:/images/sd-aboutus.png" })
    m.CategoryNames = conn.GetCategoryNames(m.Categories)
       
End Function

I would really appreciate any help!!

Thanks!

I am still struggling with how to figure this out. Does anyone have any direction they might be willing to provide. All I want to do is be able to add another category/poster to my channel with an “About Us” page…it can even be a popup dialog box. Please help!! Thanks.

@srbsdean . check your pm.

venrooy, I just sent you a private message. Hope that helps.