banner ads - mediafly

unless i missed it somewhere in the SDK

who would we go ahead and set up these type of banner ads on the bottom of the screen and click? will they only open to a video?

can they open to a with roVideoPlayer and roImageCanvas, so we can combine video, images and text on this screen?

“FML2010” wrote:
unless i missed it somewhere in the SDK

who would we go ahead and set up these type of banner ads on the bottom of the screen and click? will they only open to a video?

can they open to a with roVideoPlayer and roImageCanvas, so we can combine video, images and text on this screen?

I think you can do pretty much anything you want when an ad is clicked. See the documentation for roPosterScreen.SetAdSelectable() on page 30 of the Component Reference.

Thank you I will look more into that…

Ok after looking through all the .pdf files and searching the forum, I can not find a reference to how this actually coded.

I found it where you said it, but there is no actual example of it that i can find.

also are these static banners? i mane can we give a web address or does it need to be a “pkg” address.

I know php pretty good but so far this code is a bit confusing so please forgive me

You can do anything you want in response to an ad click event… Below is a sample code snippet that will play a video:

–Kevin


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

             videoScreen.SetContent( { url: "http://myvideo.com/myAdVideo.mp4",
                                                     StreamFormat: "mp4"
                                                   } )
              while true
                   msg = wait(0, screen.GetMessagePort())
                   if msg.isScreenClosed() then
                         return
                   endif
              end while
End Sub

'***********************************************************************************************************
' On a poster screen already setup, you can add an ad and set the display mode via:
    screen.SetAdURL(sdAdUrl, hdAdURL)
    screen.SetAdDisplayMode("scale-to-fit")

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

         ' handle other events as normal
 
         if msg.isAdSelected() then
             ' play ad video
             PlayAdVideo()
         endif
    end while

Thanks Kevin!

I am still getting no where with coding :disappointed_face:

When i add what you put here it wont even load.

If i am using the video player example, where would i put this? i think part has to do with i am still trying to get the video player and register example to work and these 3 things are not playing well together!

You need to merge the code below ‘***************’ into your poster screen.

You obviously need to change the url to a valid video on your site.

–Kevin

Kevin i have tried this and its not working here is the code i tried using

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("flat-category")
    screen.SetAdURL("http://www.puresilvabannermaker.com/bannermaker/backgroundthumbs/scale_summersun5.jpg","http://www.puresilvabannermaker.com/bannermaker/backgroundthumbs/scale_summersun5.jpg")
    screen.SetAdDisplayMode("scale-to-fit")
    while true
         msg = wait(0, screen.GetMessagePort())

         ' handle other events as normal

         if msg.isAdSelected() then
             ' play ad video
             PlayAdVideo()
         endif
    end while

    return screen

End Function

And it wont even load the poster screen… i just set the banners as something i found off the web for now…

and can i put the “SUB PLAY VIDEO” In my appMain.brs ?

Thanks and im happy to get back working on my project again

“FML2010” wrote:
And it wont even load the poster screen…

You aren’t telling it to display the poster screen. There’s no screen.Show() command.

 end while

    return screen

End Function

so should i replace the “Return screen” with " screen.Show() " ??

so why does it work like this?

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("flat-category")
    screen.SetAdURL("http://www.puresilvabannermaker.com/bannermaker/backgroundthumbs/scale_summersun5.jpg","http://www.puresilvabannermaker.com/bannermaker/backgroundthumbs/scale_summersun5.jpg")
    return screen

End Function

also Chris can i play the Sub play video on the appmain.brs ?? or its own like this – adDisplay.brs ??

Based on your code snippet, it looks like you are working from the videoplayer example, in which case, the preShowPosterScreen function does not display a screen, it builds a screen and returns it. There is then another function called showPosterScreen that takes that screen as an argument, displays it, and handles any events it generates. You have introduced an event loop into preShowPosterScreen. This loop will never catch any events and your code will never reach showPosterScreen.

And you can organize your code into whatever file structure makes the most sense to you.

Thanks Chris I got it!!

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

You need to change the Wait line (82) from:

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

to:

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

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"

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.

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 :disappointed_face: can someone please assist me? Thank you in advance :slightly_smiling_face:

'******************************************************
'** 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