I have made a grid layout for my homescreen, it work fine I still have some xml files to create, however, each row is a different Show, and the posters in the rows are different episodes of that said show. I can't get past the home screen however, i'm completely new to brightscript and I am a little lost at this point. If you could guide me in the right direction to move to the details screen and then the video screen I would be very thankful. I will post the content of my SimpleGrid.brs and my appDetailScreen.brs files.
SimpleGrid.brs:
' *********************************************************
' ** Simple Grid Screen Demonstration App
' ** Jun 2010
' ** Copyright (c) 2010 Roku Inc. All Rights Reserved.
' *********************************************************
'************************************************************
'** Application startup
'************************************************************
Sub Main()
'initialize theme attributes like titles, logos and overhang color
initTheme()
gridstyle = "Flat-Movie"
'set to go, time to get started
while gridstyle <> ""
print "starting grid style= ";gridstyle
screen=preShowGridScreen(gridstyle)
gridstyle = showGridScreen(screen, gridstyle)
end while
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")
app.SetTheme(CreateDefaultTheme())
End Sub
'******************************************************
'** @return The default application theme.
'** Screens can make slight adjustments to the default
'** theme by getting it from here and then overriding
'** individual theme attributes.
'******************************************************
Function CreateDefaultTheme() as Object
theme = CreateObject("roAssociativeArray")
theme.ThemeType = "generic-dark"
' All these are greyscales
theme.GridScreenBackgroundColor = "#363636"
theme.GridScreenMessageColor = "#808080"
theme.GridScreenRetrievingColor = "#CCCCCC"
theme.GridScreenListNameColor = "#FFFFFF"
' Color values work here
theme.GridScreenDescriptionTitleColor = "#001090"
theme.GridScreenDescriptionDateColor = "#FF005B"
theme.GridScreenDescriptionRuntimeColor = "#5B005B"
theme.GridScreenDescriptionSynopsisColor = "#606000"
'used in the Grid Screen
theme.CounterTextLeft = "#FF0000"
theme.CounterSeparator = "#00FF00"
theme.CounterTextRight = "#0000FF"
theme.GridScreenDescriptionOffsetHD = "(190,200)"
theme.GridScreenDescriptionOffsetSD = "(125,120)"
theme.GridScreenLogoHD = "pkg:/images/GSN-Header.jpg"
theme.GridScreenLogoOffsetHD_X = "0"
theme.GridScreenLogoOffsetHD_Y = "0"
theme.GridScreenOverhangHeightHD = "165"
theme.GridScreenLogoSD = "pkg:/images/GSN-Header.jpg"
theme.GridScreenOverhangHeightSD = "165"
theme.GridScreenLogoOffsetSD_X = "0"
theme.GridScreenLogoOffsetSD_Y = "0"
' to use your own focus ring artwork
'theme.GridScreenFocusBorderSD = "pkg:/images/GridCenter_Border_Movies_SD43.png"
'theme.GridScreenBorderOffsetSD = "(-26,-25)"
'theme.GridScreenFocusBorderHD = "pkg:/images/GridCenter_Border_Movies_HD.png"
'theme.GridScreenBorderOffsetHD = "(-28,-20)"
' to use your own description background artwork
'theme.GridScreenDescriptionImageSD = "pkg:/images/Grid_Description_Background_SD43.png"
'theme.GridScreenDescriptionOffsetSD = "(125,170)"
'theme.GridScreenDescriptionImageHD = "pkg:/images/Grid_Description_Background_HD.png"
'theme.GridScreenDescriptionOffsetHD = "(190,255)"
return theme
End Function
'******************************************************
'** Perform any startup/initialization stuff prior to
'** initially showing the screen.
'******************************************************
Function preShowGridScreen(style as string) As Object
m.port=CreateObject("roMessagePort")
screen = CreateObject("roGridScreen")
screen.SetMessagePort(m.port)
' screen.SetDisplayMode("best-fit")
screen.SetDisplayMode("scale-to-fill")
screen.SetGridStyle(style)
return screen
End Function
'******************************************************
'** Display the gird 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 showGridScreen(screen As Object, gridstyle as string) As string
print "enter showGridScreen"
categoryList = getCategoryList()
screen.setupLists(categoryList.count())
screen.SetListNames(categoryList)
' list holders
showListAnglerWest = CreateObject("roAssociativeArray")
showListBetterBuilt = CreateObject("roAssociativeArray")
showListCastIron = CreateObject("roAssociativeArray")
showListDRT = CreateObject("roAssociativeArray")
showListEastonBow = CreateObject("roAssociativeArray")
showListFrontier = CreateObject("roAssociativeArray")
showListKillCliff = CreateObject("roAssociativeArray")
showListJoeyMines = CreateObject("roAssociativeArray")
showListPredatorNation = CreateObject("roAssociativeArray")
showListSmacked = CreateObject("roAssociativeArray")
showListOutdoorsmanTable = CreateObject("roAssociativeArray")
showListTracks = CreateObject("roAssociativeArray")
' get lists
showListAnglerWest = getShowsForCategoryAnglerWest(categoryList[0])
showListBetterBuilt = getShowsForCategoryBetterBuilt(categoryList[1])
showListCastIron = getShowsForCategoryCastIron(categoryList[2])
showListDRT = getShowsForCategoryDRT(categoryList[3])
showListEastonBow = getShowsForCategoryEastonBow(categoryList[4])
showListFrontier = getShowsForCategoryFrontier(categoryList[5])
showListKillCliff = getShowsForCategoryKillCliff(categoryList[6])
showListJoeyMines = getShowsForCategoryJoeyMines(categoryList[7])
showListPredatorNation = getShowsForCategoryPredatorNation(categoryList[8])
showListSmacked = getShowsForCategorySmacked(categoryList[9])
showListOutdoorsmanTable = getShowsForCategoryOutdoorsmanTable(categoryList[10])
showListTracks = getShowsForCategoryTracks(categoryList[11])
' push lists to grid screen
screen.SetContentList(0, showListAnglerWest)
screen.SetContentList(1, showListBetterBuilt)
screen.SetContentList(2, showListCastIron)
screen.SetContentList(3, showListDRT)
screen.SetContentList(4, showListEastonBow)
screen.SetContentList(5, showListFrontier)
screen.SetContentList(6, showListKillCliff)
screen.SetContentList(7, showListJoeyMines)
screen.SetContentList(8, showListPredatorNation)
screen.SetContentList(9, showListSmacked)
screen.SetContentList(10, showListOutdoorsmanTable)
screen.SetContentList(11, showListTracks)
screen.Show()
while true
print "Waiting for message"
msg = wait(0, m.port)
'msg = wait(0, screen.GetMessagePort()) ' getmessageport does not work on gridscreen
print "Got Message:";type(msg)
if type(msg) = "roGridScreenEvent" then
print "msg= "; msg.GetMessage() " , index= "; msg.GetIndex(); " data= "; msg.getData()
if msg.isListItemFocused() then
print"list item focused | current show = "; msg.GetIndex()
else if msg.isListItemSelected() then
row = msg.GetIndex()
selection = msg.getData()
print "list item selected row= "; row; " selection= "; selection
' Did we get a selection from the gridstyle selection row?
if (row = 0)
' yes, return so we can come back with new style
m.curShow = displayShowDetailsScreen(showListAnglerWest, selection)
endif
if (row = 1)
m.curShow = displayShowDetailsScreen(showListBetterBuilt, selection)
endif
if (row = 2)
m.curShow = displayShowDetailsScreen(showListCastIron, selection)
endif
if (row = 3)
m.curShow = displayShowDetailsScreen(showListDRT, selection)
endif
if (row = 4)
m.curShow = displayShowDetailsScreen(showListEastonBow, selection)
endif
if (row = 5)
m.curShow = displayShowDetailsScreen(showListFrontier, selection)
endif
if (row = 6 )
m.curShow = displayShowDetailsScreen(showListKillCliff, selection)
endif
if (row = 7)
m.curShow = displayShowDetailsScreen(showListJoeyMines, selection)
endif
if (row = 😎
m.curShow = displayShowDetailsScreen(showListPredatorNation, selection)
endif
if (row = 9)
m.curShow = displayShowDetailsScreen(showListSmacked, selection)
endif
if (row = 10)
m.curShow = displayShowDetailsScreen(showListOutdoorsmanTable, selection)
endif
if(row = 11)
m.curShow = displayShowDetailsScreen(showListTracks, selection)
endif
'm.curShow = displayShowDetailScreen(showList[msg.GetIndex()])
else if msg.isScreenClosed() then
return ""
end if
end If
end while
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
'showVideoScreen(category[showIndex])
'showDetailScreen(category[showIndex])
'return 1
if validateParam(category, "roAssociativeArray", "displayShowDetailScreen") = false return -1
shows = getShowsForCategoryItem(category, m.curCategory)
screen = preShowDetailScreen(category.Title, category.kids[m.curCategory].Title)
showIndex = showDetailScreen(screen, shows, showIndex)
return showIndex
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 = [ "Angler West TV", "Better Built World of Outdoors", "Cast Iron Ranger", "Dead Right There", "Easton Bowhunting", "Frontier Unlimited", "Kill Cliff Outdoors", "Outdoors With Joey Mines", "Predator Nation", "Smacked TV", "The Outdoorsman's Table", "Tracks Across Africa"]
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 getShowsForCategoryAnglerWest(category As Object) As Object
print "getting shows for category "; category
conn = InitShowFeedConnectionAnglerWest()
showListAnglerWest = conn.LoadShowFeed(conn)
return showListAnglerWest
End Function
Function getShowsForCategoryBetterBuilt(category As Object) As Object
print "getting shows for category "; category
conn = InitShowFeedConnectionBetterBuilt()
showListBetterBuilt = conn.LoadShowFeed(conn)
return showListBetterBuilt
End Function
Function getShowsForCategoryCastIron(category As Object) As Object
print "getting shows for category "; category
conn = InitShowFeedConnectionCastIron()
showListCastIron = conn.LoadShowFeed(conn)
return showListCastIron
End Function
Function getShowsForCategoryDRT(category As Object) As Object
print "getting shows for category "; category
conn = InitShowFeedConnectionDRT()
showListDRT = conn.LoadShowFeed(conn)
return showListDRT
End Function
Function getShowsForCategoryEastonBow(category As Object) As Object
print "getting shows for category "; category
conn = InitShowFeedConnectionEastonBow()
showListEastonBow = conn.LoadShowFeed(conn)
return showListEastonBow
End Function
Function getShowsForCategoryFrontier(category As Object) As Object
print "getting shows for category "; category
conn = InitShowFeedConnectionFrontier()
showListFrontier = conn.LoadShowFeed(conn)
return showListFrontier
End Function
Function getShowsForCategoryKillCliff(category As Object) As Object
print "getting shows for category "; category
conn = InitShowFeedConnectionKillCliff()
showListKillCliff = conn.LoadShowFeed(conn)
return showListKillCliff
End Function
Function getShowsForCategoryJoeyMines(category As Object) As Object
print "getting shows for category "; category
conn = InitShowFeedConnectionJoeyMines()
showListJoeyMines = conn.LoadShowFeed(conn)
return showListJoeyMines
End Function
Function getShowsForCategoryPredatorNation(category As Object) As Object
print "getting shows for category "; category
conn = InitShowFeedConnectionPredatorNation()
showListPredatorNation = conn.LoadShowFeed(conn)
return showListPredatorNation
End Function
Function getShowsForCategorySmacked(category As Object) As Object
print "getting shows for category "; category
conn = InitShowFeedConnectionSmacked()
showListSmacked = conn.LoadShowFeed(conn)
return showListSmacked
End Function
Function getShowsForCategoryOutdoorsmanTable(category As Object) As Object
print "getting shows for category "; category
conn = InitShowFeedConnectionOutdoorsmanTable()
showListOutdoorsmanTable = conn.LoadShowFeed(conn)
return showListOutdoorsmanTable
End Function
Function getShowsForCategoryTracks(category As Object) As Object
print "getting shows for category "; category
conn = InitShowFeedConnectionTracks()
showListTracks = conn.LoadShowFeed(conn)
return showListTracks
End Function
function getGridControlButtons() as object
buttons = [
{ Title: "Flat-Movie"
ReleaseDate: "HD:5x2 SD:5x2"
Description: "Netflix style"
HDPosterUrl:"http://upload.wikimedia.org/wikipedia/en/thumb/5/52/Netflix_Logo.svg/200px-Netflix_Logo.svg.png",
SDPosterUrl:"http://upload.wikimedia.org/wikipedia/en/thumb/5/52/Netflix_Logo.svg/200px-Netflix_Logo.svg.png",
}
{ Title: "Flat-Landscape"
ReleaseDate: "HD:5x3 SD:4x3"
Description: "Channel Store"
HDPosterUrl:"http://upload.wikimedia.org/wikipedia/commons/b/b0/Adams_Evening_McDonald_Lake_Glacier_National_Park_aae06.jpg",
SDPosterUrl:"http://upload.wikimedia.org/wikipedia/commons/b/b0/Adams_Evening_McDonald_Lake_Glacier_National_Park_aae06.jpg",
}
{ Title: "Flat-Portrait"
ReleaseDate: "HD:5x2 SD:5x2"
Description: "3x4 style posters"
HDPosterUrl:"http://upload.wikimedia.org/wikipedia/commons/9/9f/Kane_George_Gurnett.jpg",
SDPosterUrl:"http://upload.wikimedia.org/wikipedia/commons/9/9f/Kane_George_Gurnett.jpg",
}
{ Title: "Flat-Square"
ReleaseDate: "HD:7x3 SD:6x3"
Description: "1x1 style posters"
HDPosterUrl:"http://upload.wikimedia.org/wikipedia/commons/thumb/d/de/SQUARE_SHAPE.svg/536px-SQUARE_SHAPE.svg.png",
SDPosterUrl:"http://upload.wikimedia.org/wikipedia/commons/thumb/d/de/SQUARE_SHAPE.svg/536px-SQUARE_SHAPE.svg.png",
}
{ Title: "Flat-16x9"
ReleaseDate: "HD:5x3 SD:4x3"
Description: "HD style posters"
HDPosterUrl:"http://upload.wikimedia.org/wikipedia/commons/thumb/2/22/%C3%89cran_TV_plat.svg/200px-%C3%89cran_TV_plat.svg.png",
SDPosterUrl:"http://upload.wikimedia.org/wikipedia/commons/thumb/2/22/%C3%89cran_TV_plat.svg/200px-%C3%89cran_TV_plat.svg.png",
}
]
return buttons
End Function
appDetailScreen.brs:
'**********************************************************
'** Video Player Example Application - Detail Screen
'** November 2009
'** Copyright (c) 2009 Roku Inc. All Rights Reserved.
'**********************************************************
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
return screen
End Function
'***************************************************************
'** The show detail screen (springboard) is where the user sees
'** the details for a show and is allowed to select a show to
'** begin playback. This is the main event loop for that screen
'** and where we spend our time waiting until the user presses a
'** button and then we decide how best to handle the event.
'***************************************************************
Function showDetailScreen(screen As Object, showList As Object, showIndex as Integer) As Integer
if validateParam(screen, "roSpringboardScreen", "showDetailScreen") = false return -1
if validateParam(showList, "roArray", "showDetailScreen") = false return -1
refreshShowDetail(screen, showList, showIndex)
'remote key id's for left/right navigation
remoteKeyLeft = 4
remoteKeyRight = 5
while true
msg = wait(0, screen.GetMessagePort())
if type(msg) = "roSpringboardScreenEvent" then
if msg.isScreenClosed()
print "Screen closed"
exit while
else if msg.isRemoteKeyPressed()
print "Remote key pressed"
if msg.GetIndex() = remoteKeyLeft then
showIndex = getPrevShow(showList, showIndex)
if showIndex <> -1
refreshShowDetail(screen, showList, showIndex)
end if
else if msg.GetIndex() = remoteKeyRight
showIndex = getNextShow(showList, showIndex)
if showIndex <> -1
refreshShowDetail(screen, showList, showIndex)
end if
endif
else if msg.isButtonPressed()
print "ButtonPressed"
print "ButtonPressed"
if msg.GetIndex() = 1
PlayStart = RegRead(showList[showIndex].ContentId)
if PlayStart <> invalid then
showList[showIndex].PlayStart = PlayStart.ToInt()
endif
showVideoScreen(showList[showIndex])
endif
if msg.GetIndex() = 2
showList[showIndex].PlayStart = 0
showVideoScreen(showList[showIndex])
endif
if msg.GetIndex() = 3
endif
print "Button pressed: "; msg.GetIndex(); " " msg.GetData()
end if
else
print "Unexpected message class: "; type(msg)
end if
end while
return showIndex
End Function
'**************************************************************
'** Refresh the contents of the show detail screen. This may be
'** required on initial entry to the screen or as the user moves
'** left/right on the springboard. When the user is on the
'** springboard, we generally let them press left/right arrow keys
'** to navigate to the previous/next show in a circular manner.
'** When leaving the screen, the should be positioned on the
'** corresponding item in the poster screen matching the current show
'**************************************************************
Function refreshShowDetail(screen As Object, showList As Object, showIndex as Integer) As Integer
if validateParam(screen, "roSpringboardScreen", "refreshShowDetail") = false return -1
if validateParam(showList, "roArray", "refreshShowDetail") = false return -1
show = showList[showIndex]
'Uncomment this statement to dump the details for each show
'PrintAA(show)
screen.ClearButtons()
screen.AddButton(1, "resume playing")
screen.AddButton(2, "play from beginning")
screen.SetContent(show)
screen.Show()
End Function
'********************************************************
'** Get the next item in the list and handle the wrap
'** around case to implement a circular list for left/right
'** navigation on the springboard screen
'********************************************************
Function getNextShow(showList As Object, showIndex As Integer) As Integer
if validateParam(showList, "roArray", "getNextShow") = false return -1
nextIndex = showIndex + 1
if nextIndex >= showList.Count() or nextIndex < 0 then
nextIndex = 0
end if
show = showList[nextIndex]
if validateParam(show, "roAssociativeArray", "getNextShow") = false return -1
return nextIndex
End Function
'********************************************************
'** Get the previous item in the list and handle the wrap
'** around case to implement a circular list for left/right
'** navigation on the springboard screen
'********************************************************
Function getPrevShow(showList As Object, showIndex As Integer) As Integer
if validateParam(showList, "roArray", "getPrevShow") = false return -1
prevIndex = showIndex - 1
if prevIndex < 0 or prevIndex >= showList.Count() then
if showList.Count() > 0 then
prevIndex = showList.Count() - 1
else
return -1
end if
end if
show = showList[prevIndex]
if validateParam(show, "roAssociativeArray", "getPrevShow") = false return -1
return prevIndex
End Function
Current Roku Channel for Global Sportsman Network(http://globalsportsman.com)