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: 
Blackhawk
Level 7

It wont display the channel

I had made a new code for one of my shows

Function CreateHomeworkHelperzMenu() as integer
screen = CreateObject("roGridScreen")
port = CreateObject("roMessagePort")
screen.SetMessagePort(port)

screen.SetBreadcrumbText("HomeworkHelperz", "Full Menu")
screen.SetupLists(2)
screen.SetListNames(["2016"])

screen.SetContentList(0, GetHomeworkHelperzMenuOptions_2016())

screen.show()

while (true)
msg = wait(0, port)
if type(msg) = "roPosterScreenEvent"
if (msg.isScreenClosed())
return -1
else if (msg.isListItemSelected())
ShowHomeworkHelperzDetails( msg.GetIndex() )
endif
endif

end while
End Function


'*************************************************************
'** showSpringboardScreen()
'*************************************************************

Function ShowHomeworkHelperzDetails(index as integer) as integer
print "Selected Index: " + Stri(index)
detailsScreen = CreateObject("roSpringboardScreen")
port = CreateObject("roMessagePort")
detailsScreen.SetMessagePort(port)
detailsScreen.SetDescriptionStyle("generic")
detailsScreen.SetBreadcrumbText("HomeworkHelperz", m.options[index].ShortDescriptionLine1)
detailsScreen.SetStaticRatingEnabled(false)

details = {
HDPosterUrl: m.options[index].HDPosterURL
SDPosterUrl: m.options[index].SDPosterURL
Description: m.options[index].ShortDescriptionLine1
LabelAttrs: ["Price:", "Calories per Serving:"]
LabelVals: [m.options[index].Price, m.options[index].Calories]
}
detailsScreen.SetContent(details)
detailsScreen.AddButton(1, "Play")
detailsScreen.AddButton(2, "")
detailsScreen.show()

while (true)
msg = wait(0, port)
if type(msg) = "roSpringboardScreenEvent"
if (msg.isScreenClosed())
return -1
else if (msg.isButtonPressed())
DetailsScreenButtonClicked( msg.GetIndex() )
endif
endif
end while
End Function

Function DetailsScreenButtonClicked(index as integer) as void
dialog = CreateObject("roOneLineDialog")
if (index = 1)
ShowVideoScreen(video)
else if (index = 2)
dialog.SetTitle("")
endif
dialog.ShowBusyAnimation()
dialog.show()

Sleep(4000)
End Function

sub ShowVideoScreen(video)
port = CreateObject("roMessagePort")
screen = CreateObject("roVideoScreen")
screen.SetMessagePort(port)
screen.SetContent(video)

screen.Show()

while true
msg = wait(0, port)

if type(msg) = "roVideoScreenEvent"
if msg.isScreenClosed()
exit while
end if
end if
end while

screen.Close()
end sub

Function PlayVideoContent(content as Object) as Object
' roVideoScreen just closes if you try to resume or seek after ad playback,
' so just create a new instance of the screen...
videoScreen = CreateObject("roVideoScreen")
videoScreen.SetContent(content)
' need a reasonable notification period set if midroll/postroll ads are to be
' rendered at an appropriate time
videoScreen.SetPositionNotificationPeriod(1)
videoScreen.SetMessagePort(CreateObject("roMessagePort"))
videoScreen.Show()

return videoScreen
End Function

Sub PlayContentWithAds(videoContent as Object)
canvas = CreateObject("roImageCanvas")
canvas.SetLayer(1, {color: "#000000"})
canvas.SetLayer(2, {text: "Loading..."})
canvas.Show()

adIface = Roku_Ads()
print "Roku_Ads library version: " + adIface.getLibVersion()
' Normally, would set publisher's ad URL here. Otherwise uses default Roku ad server (with single preroll placeholder ad)
'adIface.setAdUrl()

adPods = adIface.getAds()
playContent = adIface.showAds(adPods) ' show preroll ad pod (if any)

curPos = 0
if playContent
videoScreen = PlayVideoContent(videoContent)
end if

closingContentScreen = false
contentDone = false
while playContent
videoMsg = wait(0, videoScreen.GetMessagePort())
if type(videoMsg) = "roVideoScreenEvent"
if videoMsg.isStreamStarted()
canvas.ClearLayer(2)
end if
if videoMsg.isPlaybackPosition()
' cache current playback position for resume after midroll ads
curPos = videoMsg.GetIndex()
end if

if not closingContentScreen ' don't check for any more ads while waiting for screen close
if videoMsg.isScreenClosed() ' roVideoScreen sends this message last for all exit conditions
playContent = false
else if videoMsg.isFullResult()
contentDone = true ' don't want to resume playback after postroll ads
end if

' check for midroll/postroll ad pods
adPods = adIface.getAds(videoMsg)
if adPods <> invalid and adPods.Count() > 0
' must completely close content screen before showing ads
' for some Roku platforms (e.g., RokuTV), calling Close() will not synchronously
' close the media player and may prevent a new media player from being created
' until the screen is fully closed (app has received the isScreenClosed() event)
videoScreen.Close()
closingContentScreen = true
end if
else if videoMsg.isScreenClosed()
closingContentScreen = false ' now safe to render ads
end if ' closingContentScreen

if not closingContentScreen and adPods <> invalid and adPods.Count() > 0
' now safe to render midroll/postroll ads
playContent = adIface.showAds(adPods)
playContent = playContent and not contentDone
if playContent
' resume video playback after midroll ads
videoContent.PlayStart = curPos
videoScreen = PlayVideoContent(videoContent)
end if
end if ' !closingContentScreen
end if ' roVideoScreenEvent
end while
if type(videoScreen) = "roVideoScreen" then videoScreen.Close()
End Sub


Function GetHomeworkHelperzMenuOptions_2016() as object
options = [
{ Title: "Fruit"
Price: "$2.99"
Calories: "200"
Description: "A Variety of Fresh Fruit"
HDPosterUrl:"pkg://images/fruit.jpg"
SDPosterUrl:"pkg://images/fruit.jpg"
}
]
return options
End Function





It wont display the channel, it has a compile error "&ha7" on line 93
0 Kudos
2 Replies
Roku Employee
Roku Employee

Re: It wont display the channel

Well, I put your code into a project. I added a sub main() since that vital bit is missing from the code you shared. The code compiled without error. Something else must be wrong with your app. I even put

sub main()

createHomeworkHelperzMenu()

end sub


And that worked. There doesn't appear to be anything wrong with the code you posted, so the problem may be in whatever code you didn't post.

- Joel
0 Kudos
Blackhawk
Level 7

Re: It wont display the channel

Like this?




sub main()

createHomeworkHelperzMenu()
screen = CreateObject("roGridScreen")
port = CreateObject("roMessagePort")
screen.SetMessagePort(port)

screen.SetBreadcrumbText("Lunch", "Full Menu")
screen.SetupLists(2)
screen.SetListNames(["2016"])

screen.SetContentList(0, GetHomeworkHelperzMenuOptions_2016())

screen.show()

while (true)
msg = wait(0, port)
if type(msg) = "roGridScreenEvent"
if (msg.isScreenClosed())
return -1
else if (msg.isListItemSelected())
showSpringboardScreen( msg.GetIndex() )

endif
endif
end while
end sub
0 Kudos