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

SimplePoster.brs

How do I program the displayShowDetailScreen into the showPosterScreen? inside of the SimplePoster.brs.
Here is what I have to work with.
' *********************************************************
' ** Simple Poster Screen Demonstration App
' ** Nov 2009
' ** Copyright (c) 2009 Roku Inc. All Rights Reserved.
' *********************************************************

'************************************************************
'** Application startup
'************************************************************
Sub Main()

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

'prepare the screen for display and get ready to begin
screen=preShowPosterScreen("", "")
if screen=invalid then
print "unexpected error in preShowPosterScreen"
return
end if

'set to go, time to get started
showPosterScreen(screen)



End Sub


'*************************************************************
'** Set the configurable theme attributes for the application
'**
'** Configure the custom overhang and Logo attributes
'** These attributes affect the branding of the application
'** and are artwork, colors and offsets specific to the app
'*************************************************************

Sub initTheme()

app = CreateObject("roAppManager")
theme = CreateObject("roAssociativeArray")

theme.OverhangOffsetSD_X = "72"
theme.OverhangOffsetSD_Y = "25"
theme.OverhangLogoSD = "pkg:/images/AV.png"

theme.OverhangOffsetHD_X = "123"
theme.OverhangOffsetHD_Y = "48"
theme.OverhangLogoHD = "pkg:/images/AV.png"

app.SetTheme(theme)

End Sub

'******************************************************
'** Perform any startup/initialization stuff prior to
'** initially showing the screen.
'******************************************************
Function preShowPosterScreen(breadA=invalid, breadB=invalid) As Object

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

screen.SetListStyle("arced-landscape")
return screen

End Function


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

categoryList = getCategoryList()
screen.SetListNames(categoryList)
screen.SetContentList(getShowsForCategoryItem(categoryList[0]))
screen.Show()

while true
msg = wait(0, screen.GetMessagePort())
if type(msg) = "roPosterScreenEvent" then
print "showPosterScreen | msg = "; msg.GetMessage() " | index = "; msg.GetIndex()
if msg.isListFocused() then
'get the list of shows for the currently selected item
screen.SetContentList(getShowsForCategoryItem(categoryList[msg.GetIndex()]))
print "list focused | current category = "; msg.GetIndex()
else if msg.isListItemFocused() then
print"list item focused | current show = "; msg.GetIndex()
else if msg.isListItemSelected() then

print "list item selected | current show = "; msg.GetIndex()

'if you had a list of shows, the index of the current item
'is probably the right show, so you'd do something like this

'm.curShow = displayShowDetailScreen(showList[msg.GetIndex()])
displayBase64()
else if msg.isScreenClosed() then
return -1
end if
end If
end while


End Function

Function displayBase64()
ba = CreateObject("roByteArray")
str = "Aladdin:open sesame"
ba.FromAsciiString(str)
result = ba.ToBase64String()
print result

ba2 = CreateObject("roByteArray")
ba2.FromBase64String(result)
result2 = ba2.ToAsciiString()
print result2
End Function


'**********************************************************
'** When a poster on the home screen is selected, we call
'** this function passing an roAssociativeArray with the
'** ContentMetaData for the selected show. This data should
'** be sufficient for the springboard to display
'**********************************************************
Function displayShowDetailScreen(category as Object, showIndex as Integer) As Integer

port = CreateObject("roMessagePort")
displayShowDetailScreen = CreateObject("roSpringboardScreen")
displayShowDetailScreen.SetBreadcrumbText("[location 1]", "[location2]")
displayShowDetailScreen.SetMessagePort(port)
o = CreateObject("roAssociativeArray")
o.ContentType = "episode"
o.Title = "[Title]"
displayShowDetailScreen.AddButton(1, "[Exit]")
o.ShortDescriptionLine1 = "[ShortDescriptionLine1]"
o.ShortDescriptionLine2 = "[ShortDescriptionLine2]"
o.Description = ""
for i = 1 to 15
o.Description = o.Description + "[Description] "
end for
o.SDPosterUrl = ""
o.HDPosterUrl = ""
o.Rating = "NR"
o.StarRating = "75"
o.ReleaseDate = "[mm/dd/yyyy]"
o.Length = 5400
o.Categories = CreateObject("roArray", 10, true)
o.Categories.Push("[Category1]")
o.Categories.Push("[Category2]")
o.Categories.Push("[Category3]")
o.Actors = CreateObject("roArray", 10, true)
o.Actors.Push("[Actor1]")
o.Actors.Push("[Actor2]")
o.Actors.Push("[Actor3]")
o.Director = "[Director]"
displayShowDetailScreen.SetContent(o)
displayShowDetailScreen.Show()
while true
msg = wait(0, port)
if type(msg) = "roSpringboardScreenEvent" then
if msg.isScreenClosed() then
return showList
else if msg.isButtonPressed()
print "button pressed: ";msg.GetIndex()
end if
end if
end while

End Function
0 Kudos
1 REPLY 1
RokuKevin
Visitor

Re: SimplePoster.brs

Please go through the Developer Guide to get the gist of using the BrightScript debugger to help in walking through the code...

I made some modifications to your sample here to show the next steps to adding the SpringBoard screen.

--Kevin

' *********************************************************
' ** Simple Poster Screen Demonstration App
' ** Nov 2009
' ** Copyright (c) 2009 Roku Inc. All Rights Reserved.
' *********************************************************

'************************************************************
'** Application startup
'************************************************************
Sub Main()

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

'prepare the screen for display and get ready to begin
screen=preShowPosterScreen("", "")
if screen=invalid then
print "unexpected error in preShowPosterScreen"
return
end if

'set to go, time to get started
showPosterScreen(screen)



End Sub


'*************************************************************
'** Set the configurable theme attributes for the application
'**
'** Configure the custom overhang and Logo attributes
'** These attributes affect the branding of the application
'** and are artwork, colors and offsets specific to the app
'*************************************************************

Sub initTheme()

app = CreateObject("roAppManager")
theme = CreateObject("roAssociativeArray")

theme.OverhangOffsetSD_X = "72"
theme.OverhangOffsetSD_Y = "25"
theme.OverhangLogoSD = "pkg:/images/AV.png"

theme.OverhangOffsetHD_X = "123"
theme.OverhangOffsetHD_Y = "48"
theme.OverhangLogoHD = "pkg:/images/AV.png"

app.SetTheme(theme)

End Sub

'******************************************************
'** Perform any startup/initialization stuff prior to
'** initially showing the screen.
'******************************************************
Function preShowPosterScreen(breadA=invalid, breadB=invalid) As Object

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

screen.SetListStyle("arced-landscape")
return screen

End Function


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

categoryList = getCategoryList()
screen.SetListNames(categoryList)
showList = getShowsForCategoryItem(categoryList[0])
screen.SetContentList(showList)
screen.Show()

while true
msg = wait(0, screen.GetMessagePort())
if type(msg) = "roPosterScreenEvent" then
print "showPosterScreen | msg = "; msg.GetMessage() " | index = "; msg.GetIndex()
if msg.isListFocused() then
'get the list of shows for the currently selected item
showList = getShowsForCategoryItem(categoryList[msg.GetIndex()])
screen.SetContentList(showList)
print "list focused | current category = "; msg.GetIndex()
else if msg.isListItemFocused() then
print"list item focused | current show = "; msg.GetIndex()
else if msg.isListItemSelected() then

print "list item selected | current show = "; msg.GetIndex()

'if you had a list of shows, the index of the current item
'is probably the right show, so you'd do something like this
m.curShow = displayShowDetailScreen(showList, msg.GetIndex())
displayBase64()
else if msg.isScreenClosed() then
return -1
end if
end If
end while


End Function

Function displayBase64()
ba = CreateObject("roByteArray")
str = "Aladdin:open sesame"
ba.FromAsciiString(str)
result = ba.ToBase64String()
print result

ba2 = CreateObject("roByteArray")
ba2.FromBase64String(result)
result2 = ba2.ToAsciiString()
print result2
End Function


'**********************************************************
'** When a poster on the home screen is selected, we call
'** this function passing an roAssociativeArray with the
'** ContentMetaData for the selected show. This data should
'** be sufficient for the springboard to display
'**********************************************************
Function displayShowDetailScreen(category as Object, showIndex as Integer) As Integer

print "displayShowDetailScreen type(category)"; type(category); " showIndex "; showIndex
port = CreateObject("roMessagePort")
displayShowDetailScreen = CreateObject("roSpringboardScreen")
displayShowDetailScreen.SetBreadcrumbText("[location 1]", "[location2]")
displayShowDetailScreen.SetMessagePort(port)
o = CreateObject("roAssociativeArray")
o.ContentType = "episode"
o.Title = category[showIndex].ShortDescriptionLine1
displayShowDetailScreen.AddButton(1, "[Exit]")
o.ShortDescriptionLine1 = category[showIndex].ShortDescriptionLine1
o.ShortDescriptionLine2 = category[showIndex].ShortDescriptionLine2
o.Description = ""
for i = 1 to 15
o.Description = o.Description + "[Description] "
end for
o.SDPosterUrl = ""
o.HDPosterUrl = ""
o.Rating = "NR"
o.StarRating = "75"
o.ReleaseDate = "[mm/dd/yyyy]"
o.Length = 5400
o.Categories = CreateObject("roArray", 10, true)
o.Categories.Push("[Category1]")
o.Categories.Push("[Category2]")
o.Categories.Push("[Category3]")
o.Actors = CreateObject("roArray", 10, true)
o.Actors.Push("[Actor1]")
o.Actors.Push("[Actor2]")
o.Actors.Push("[Actor3]")
o.Director = "[Director]"
displayShowDetailScreen.SetContent(o)
displayShowDetailScreen.Show()
while true
msg = wait(0, port)
if type(msg) = "roSpringboardScreenEvent" then
if msg.isScreenClosed() then
return showList
else if msg.isButtonPressed()
print "button pressed: ";msg.GetIndex()
end if
end if
end while

End Function



'**************************************************************
'** Return the list of categories to display in the filter
'** banner. The result is an roArray containing the names of
'** all of the categories. All just static data for the example.
'***************************************************************
Function getCategoryList() As Object

categoryList = CreateObject("roArray", 10, true)

categoryList = [ "Comedy", "Drama", "News", "Reality", "Daytime" ]
return categoryList

End Function


'********************************************************************
'** Given the category from the filter banner, return an array
'** of ContentMetaData objects (roAssociativeArray's) representing
'** the shows for the category. For this example, we just cheat and
'** create and return a static array with just the minimal items
'** set, but ideally, you'd go to a feed service, fetch and parse
'** this data dynamically, so content for each category is dynamic
'********************************************************************
Function getShowsForCategoryItem(category As Object) As Object

print "getting shows for category "; category

showList = [
{
ShortDescriptionLine1:"Show #1",
ShortDescriptionLine2:"Short Description for Show #1",
}
{
ShortDescriptionLine1:"Show #2",
ShortDescriptionLine2:"Short Description for Show #2",
HDPosterUrl:"pkg:/media/bogusFileName_hd.jpg",
SDPosterUrl:"pkg:/media/bogusFileName_hd.jpg"
}
{
ShortDescriptionLine1:"Show #3",
ShortDescriptionLine2:"Short Description for Show #3",
}
]

return showList

End Function

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.