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

Re: banner ads - mediafly

Thanks Chris I got it!!
0 Kudos
uarlive
Visitor

Re: banner ads - mediafly

Hello. I almost have this working and need a little help. here is the code i have so far. i can select the banner ad but i believe the issue is in the PlayAdVideo function. I used the same function code that was posted earlier. thanks in advance

screen.SetListNames(getCategoryList(category))
screen.SetContentList(getShowsForCategoryItem(category, m.curCategory))
screen.SetAdURL("http://.jpg","http://.jpg")
screen.SetAdDisplayMode("scale-to-fit")
screen.SetAdSelectable(true)
screen.Show()

while true
msg = wait(0, screen.GetMessagePort())
if type(msg) = "roPosterScreenEvent" then
print "showPosterScreen | msg = "; msg.GetMessage() " | index = "; msg.GetIndex()
if msg.isAdSelected() then
PlayAdVideo()


I

here is the debugger response.

Current Function:
076: Sub PlayAdVideo()
077: videoScreen = CreateObject("roVideoScreen")
078: port = CreateObject("roMessagePort")
079: videoScreen.SetMessagePort(port)
080: videoScreen.SetContent( { url: "http:///musicvideos/-720.mp4", StreamFormat: "mp4"} )
081: while true
082: msg = wait(0, screen.GetMessagePort())
083: if msg.isScreenClosed() then
084: return
085: endif
086: end while
087:
088: End Sub
/tmp/plugin/DOAAAADKf239/pkg:/source/appPosterScreen.brs(82): runtime error ec: 'Dot' Operator attempted with invalid BrightScript Component or interface reference.

082: msg = wait(0, screen.GetMessagePort())

Backtrace:
Function playadvideo() As Void
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:
global &h07 rotINTERFACE:ifGlobal
m &h06 bsc:roAssociativeArray, refcnt=6
videoscreen &h16 bsc:roVideoScreen, refcnt=1
port &h16 bsc:roMessagePort, refcnt=2
msg &h30 Untyped val:Uninitialized
screen &h30 Untyped val:Uninitialized
0 Kudos
TheEndless
Channel Surfer

Re: banner ads - mediafly

You need to change the Wait line (82) from:
msg = wait(0, screen.GetMessagePort())

to:
msg = wait(0, videoscreen.GetMessagePort())
My Channels: http://roku.permanence.com - Twitter: @TheEndlessDev
Instant Watch Browser (NetflixIWB), Aquarium Screensaver (AQUARIUM), Clever Clocks Screensaver (CLEVERCLOCKS), iTunes Podcasts (ITPC), My Channels (MYCHANNELS)
0 Kudos
uarlive
Visitor

Re: banner ads - mediafly

thanks endless. i get this error now in my playadvideo function.

Current Function:
076: Sub PlayAdVideo()
077: videoScreen = CreateObject("roVideoScreen")
078: port = CreateObject("roMessagePort")
079: videoScreen.SetMessagePort(port)
080: videoScreen.StreamUrls = "http://720.mp4"
081: videoScreen.StreamFormat = "mp4"
082: videoScreen.ContentType = "video"
083: videoScreen.SetContent(episode)
084: videoScreen.SetMessagePort(port)
085: videoScreen.Show()
086: while true
087: msg = wait(0, videoscreen.GetMessagePort())
088: if type(msg) = "roVideoScreenEvent" then
089: print "showPosterScreen | msg = "; msg.GetMessage() " | index = "; msg.GetIndex()
090: if msg.isScreenClosed() then
091: exit while
092:
093: endif
094: endif
095: end while
096:
097: End Sub
/tmp/plugin/JPAAAAAlMm74/pkg:/source/appPosterScreen.brs(80): runtime error e9: Use of uninitialized variable

080: videoScreen.StreamUrls = "http://720.mp4"
0 Kudos
TheEndless
Channel Surfer

Re: banner ads - mediafly

It looks like your code got mangled up somewhere. Try something like this instead (untested):

Sub PlayAdVideo()
videoScreen = CreateObject("roVideoScreen")
port = CreateObject("roMessagePort")
videoScreen.SetMessagePort(port)
episode = {
Stream: { Url: "http://720.mp4" }
StreamFormat: "mp4"
}
videoScreen.SetContent(episode)
videoScreen.Show()
while true
msg = wait(0, videoscreen.GetMessagePort())
if type(msg) = "roVideoScreenEvent" then
if msg.isScreenClosed() then
exit while
endif
endif
end while
End Sub

You'll need to correct the stream URL, too, as the one in your sample isn't valid.
My Channels: http://roku.permanence.com - Twitter: @TheEndlessDev
Instant Watch Browser (NetflixIWB), Aquarium Screensaver (AQUARIUM), Clever Clocks Screensaver (CLEVERCLOCKS), iTunes Podcasts (ITPC), My Channels (MYCHANNELS)
0 Kudos
kasiris
Channel Surfer

Re: banner ads - mediafly

I have been stuck trying to figure out the above post and this is how far I have gotten, problem is the video still will not play 😞 can someone please assist me? Thank you in advance 🙂

'******************************************************
'** Video Player Example Application -- Poster Screen
'** November 2009
'** Copyright (c) 2009 Roku Inc. All Rights Reserved.
'******************************************************

'******************************************************
'** Perform any startup/initialization stuff prior to
'** initially showing the screen.
'******************************************************

Sub PlayAdVideo()
videoScreen = CreateObject("roVideoScreen")
port = CreateObject("roMessagePort")
videoScreen.SetMessagePort(port)

videoScreen.SetContent( { url: "http://video.ted.com/talks/podcast/ImogenHeap_WaitItOut_2009G_480.mp4",
StreamFormat: "mp4"
} )
while true
msg = wait(0, videoscreen.GetMessagePort())
if msg.isScreenClosed() then
return
endif
end while
End Sub
Function preShowPosterScreen(breadA=invalid, breadB=invalid) As Object

if validateParam(breadA, "roString", "preShowPosterScreen", true) = false return -1
if validateParam(breadB, "roString", "preShowPosterScreen", 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("arced-landscape")

screen.SetAdUrl("http://roku.net23.net/main/appPosterScreenBannerVideoshopSD_540x160_roku.jpg", "http://roku.net23.net/main/appPosterScreenBannerVideoshopHD_728x90_roku.jpg")


screen.SetAdDisplayMode("scale-to-fit")
screen.SetAdSelectable(true)
screen.Show()
return screen

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

' handle other events as normal

if msg.isAdSelected() then
' play ad video
PlayAdVideo()
endif
end while
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 showPosterScreen(screen As Object, category As Object) As Integer

if validateParam(screen, "roPosterScreen", "showPosterScreen") = false return -1
if validateParam(category, "roAssociativeArray", "showPosterScreen") = false return -1

m.curCategory = 0
m.curShow = 0
temp=getcategorylist(category)


if temp.count() > 1 then
screen.SetListNames(temp)
?temp.count();" categories"
else
?"only ";temp.count();" category"
end if
screen.SetContentList(getShowsForCategoryItem(category, m.curCategory))
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
m.curCategory = msg.GetIndex()
m.curShow = 0
screen.setcontentlist([])
screen.SetFocusedListItem(m.curShow)
screen.showmessage("Retrieving")
screen.SetContentList(getShowsForCategoryItem(category, m.curCategory))
screen.clearmessage()
print "list focused | current category = "; m.curCategory
else if msg.isListItemSelected() then
m.curShow = msg.GetIndex()
print "list item selected | current show = "; m.curShow
m.curShow = displayShowDetailScreen(category, m.curShow)
screen.SetFocusedListItem(m.curShow)
print "list item updated | new show = "; m.curShow
else if msg.isScreenClosed() then
return -1
end if
end If
end while


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 displayShowDetailScreen(category as Object, showIndex as Integer) As Integer

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


'**************************************************************
'** Given an roAssociativeArray representing a category node
'** from the category feed tree, return an roArray containing
'** the names of all of the sub categories in the list.
'***************************************************************
Function getCategoryList(topCategory As Object) As Object

if validateParam(topCategory, "roAssociativeArray", "getCategoryList") = false return -1

if type(topCategory) <> "roAssociativeArray" then
print "incorrect type passed to getCategoryList"
return -1
endif

categoryList = CreateObject("roArray", 100, true)
for each subCategory in topCategory.Kids
categoryList.Push(subcategory.Title)
next
return categoryList

End Function

'********************************************************************
'** Return the list of shows corresponding the currently selected
'** category in the filter banner. As the user highlights a
'** category on the top of the poster screen, the list of posters
'** displayed should be refreshed to corrrespond to the highlighted
'** item. This function returns the list of shows for that category
'********************************************************************
Function getShowsForCategoryItem(category As Object, item As Integer) As Object

if validateParam(category, "roAssociativeArray", "getCategoryList") = false return invalid

conn = InitShowFeedConnection(category.kids[item])
showList = conn.LoadShowFeed(conn)
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.