Roku Developer Program

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

get menu from a url

I am developing a channel with an example that comes on the blog, but I want the menu as carge from a server as well as the videoplayer that come with the SDK this is the code someone can help me



Function Main() as void

' m.menuFunctions = [
'Url: "http://page/json/breakfastMenu.brs"

' ]
screen = CreateObject("roListScreen")
screens = CreateObject("roUrlTransfer")
port = CreateObject("roMessagePort")
ports = CreateObject("roMessagePort")
screen.SetMessagePort(port)
screens.SetMessagePort(ports)
InitTheme()
screen.SetHeader("Welcome to The Channel Diner")
screen.SetBreadcrumbText("Menu", "")

contentList = InitContentList()
screen.SetContent(contentList)
screen.show()





screens.AsyncGetToFile(contentList)
screens.show()
ms = "roUrlTransfer"
'request = CreateObject("roUrlTransfer")
' port = CreateObject("roMessagePort")
'request.SetMessagePort(port)
' request.SetUrl("http://page/json/breakfastMenu.brs")

while (true)
msg = wait(0, port)
if (type(msg) = "roListScreenEvent")
if (msg.isListItemFocused())
screen.SetBreadcrumbText("Menu", contentList[msg.GetIndex()].Title)

else if (msg.isListItemSelected())
request.SetUrl([msg.GetString()].Url)
'm.menuFunctions[msg.GetIndex()].Url()
endif
endif
end while
End Function

Function InitTheme() as void
app = CreateObject("roAppManager")

listItemHighlight = "#FFFFFF"
listItemText = "#707070"
brandingGreen = "#37491D"
backgroundColor = "#e0e0e0"
theme = {
BackgroundColor: backgroundColor
OverhangSliceHD: "pkg:/images/Overhang_Slice_HD.png"
OverhangSliceSD: "pkg:/images/Overhang_Slice_HD.png"
OverhangLogoHD: "pkg:/images/channel_diner_logo.png"
OverhangLogoSD: "pkg:/images/channel_diner_logo.png"
OverhangOffsetSD_X: "25"
OverhangOffsetSD_Y: "15"
OverhangOffsetHD_X: "25"
OverhangOffsetHD_Y: "15"
BreadcrumbTextLeft: brandingGreen
BreadcrumbTextRight: "#E1DFE0"
BreadcrumbDelimiter: brandingGreen

ListItemText: listItemText
ListItemHighlightText: listItemHighlight
ListScreenDescriptionText: listItemText
ListItemHighlightHD: "pkg:/images/select_bkgnd.png"
ListItemHighlightSD: "pkg:/images/select_bkgnd.png"
CounterTextLeft: brandingGreen
CounterSeparator: brandingGreen
GridScreenBackgroundColor: backgroundColor
GridScreenListNameColor: brandingGreen
GridScreenDescriptionTitleColor: brandingGreen
GridScreenLogoHD: "pkg://images/channel_diner_logo.png"
GridScreenLogoSD: "pkg://images/channel_diner_logo.png"
GridScreenOverhangHeightHD: "138"
GridScreenOverhangHeightSD: "138"
GridScreenOverhangSliceHD: "pkg:/images/Overhang_Slice_HD.png"
GridScreenOverhangSliceSD: "pkg:/images/Overhang_Slice_HD.png"
GridScreenLogoOffsetHD_X: "25"
GridScreenLogoOffsetHD_Y: "15"
GridScreenLogoOffsetSD_X: "25"
GridScreenLogoOffsetSD_Y: "15"
}
app.SetTheme( theme )
End Function

Function InitContentList() as object

request = CreateObject("roUrlTransfer")
port = CreateObject("roMessagePort")
request.SetMessagePort(port)
request.SetUrl("http://page/json/")
contentList = [
{
Title: "Breakfastdert",
ID: "1",
Url: "breakfastMenu.brs"
SDSmallIconUrl: "pkg:/images/breakfast_small.png",
HDSmallIconUrl: "pkg:/images/breakfast_small.png",
HDBackgroundImageUrl: "pkg:/images/breakfast_large.png",
SDBackgroundImageUrl: "pkg:/images/breakfast_large.png",
ShortDescriptionLine1: "Breakfast Menu",
ShortDescriptionLine2: "Select from our award winning offerings"
},
{
Title: "Lunch",
ID: "2",
SDSmallIconUrl: "pkg:/images/lunch_small.png",
HDSmallIconUrl: "pkg:/images/lunch_small.png",
HDBackgroundImageUrl: "pkg:/images/lunch_large.png",
SDBackgroundImageUrl: "pkg:/images/lunch_large.png",
ShortDescriptionLine1: "Lunch Menu",
ShortDescriptionLine2: "Eating again already?"
},
{
Title: "Dinner",
ID: "3",
SDSmallIconUrl: "pkg:/images/dinner_small.png",
HDSmallIconUrl: "pkg:/images/dinner_small.png",
HDBackgroundImageUrl: "pkg:/images/dinner_large.png",
SDBackgroundImageUrl: "pkg:/images/dinner_large.png",
ShortDescriptionLine1: "Dinner Menu",
ShortDescriptionLine2: "Selecting this menu doesn't do anything"
},
{
Title: "Desserts",
ID: "4",
SDSmallIconUrl: "pkg:/images/dessert_small.png",
HDSmallIconUrl: "pkg:/images/dessert_small.png",
HDBackgroundImageUrl: "pkg:/images/dessert_large.png",
SDBackgroundImageUrl: "pkg:/images/dessert_large.png",
ShortDescriptionLine1: "Dessert Menu",
ShortDescriptionLine2: "Selecting this menu doesn't do anything"
}
{
Title: "Contact The Diner",
ID: "5",
SDSmallIconUrl: "pkg:/images/about_small.png",
HDSmallIconUrl: "pkg:/images/about_small.png",
HDBackgroundImageUrl: "pkg:/images/about_large.png",
SDBackgroundImageUrl: "pkg:/images/about_large.png",
ShortDescriptionLine1: "The Channel Diner",
ShortDescriptionLine2: "Selecting this menu doesn't do anything"
}
]
return contentList
End Function


Appreciate very much your help in advance thank you very much for your attention Smiley Very Happy
0 Kudos
1 Reply
sotosmonster
Level 7

Re: get menu from a url

Please help.
0 Kudos