Where within the code on the PosterScreen is the correct place to type in the setadurl? Is it after this:
screen.SetListNames(getCategoryList(category))
screen.SetContentList(getShowsForCategoryItem(category, m.curCategory))
Thanks in advance.
Where within the code on the PosterScreen is the correct place to type in the setadurl? Is it after this:
screen.SetListNames(getCategoryList(category))
screen.SetContentList(getShowsForCategoryItem(category, m.curCategory))
Thanks in advance.
This would be best (right before those lines calling SetListNames and SetContentList):
screen.SetAdURL(sdAdURL, hdAdURL)
screen.SetListNames(getCategoryList(category))
screen.SetContentList(getShowsForCategoryItem(category, m.curCategory))
Cheers,
Jon
Thank you Jon!!
I attempted to edit the posterscreen.brs to add the test url of a sample graphic for the display advertisement. My first attempt didn’t work.
Before making too many changes…the image for the test display ad, should it be in the image folder on the server side or in the image folder on the device side where I have the channel images that the manifest refers too?
Thank you.
If I’m not mistaken, I believe the ad url has to be an http URL. A local image won’t work.
EDIT: Yep, see RokuKevin’s response here: viewtopic.php?f=34&t=33206&p=230179#p230179
I must have done something incorrect in the coding or placement.
Thank you.
It also only works in two screen types.
I’n sure it’s me because I am new at this. I am using the arced-landscape.
I also need to find a way to have the ads dynamically changed. I know about some scripts but how to apply them is another learning curve.
Thank you.
If you know of a tutorial on how to apply the scripts to get the display ads working, please let me know. Important I get this part of the channel working.
Thank you.
Within the following pasted code below, can someone tell me where to place this information? I have tried several spots but I cannot get the adURL to work. Also, can someone tell me how to use a PhP ad rotating script? Is it code I put on my server which also includes the url to the image? My goal is to first get a diplay ad to show on the posterscreen and next then to figure out how to get the ads to change randomly without me having to change the ads manually each week.
screen.SetAdURL(“http://myserver.com/mySDadvertisement.jpg”, “http://myserver.com/myHDadvertisement.jpg”)
'******************************************************
'** 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.
'******************************************************
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”)
return screen
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
newchannel,
Here is where I put my code in appPosterScreen.brs Later I will make it clickable to call the playadvideo routine.
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)
’ More Banner Ad settings
screen.SetAdUrl(“http://www.xxx.com/roku/banner/sdbanner1.jpg”,“http://www.xxx.com/roku/banner/hdbanner1.jpg”)
screen.SetListNames(getCategoryList(category))
screen.SetContentList(getShowsForCategoryItem(category, m.curCategory))
screen.SetAdDisplayMode(“scale-to-fit”)
screen.SetAdSelectable(false)
screen.Show()
’ End Banner settings
if temp.count() > 1 then
Hi bandal,
Thanks for posting the code.
I added it on my posterscreen.brs, zipped and loaded to device. Not just on this try but on all tries with your code and my own code from before my channel dissappears from the device. Then when i go back to posterscreen.brs before changes and rezip, my channel shows back up.
Debug says syntax error but I can;t seem to find it. I’ll see if I can post here what debugger shows in next reply.
Here is what debugger says:
*** ERROR compiling /pkg:/source/appPosterScreen.brs:
Syntax Error. (compile error &h02) in …g:/source/appPosterScreen.brs(73)
Note: GC - Found 97 orphaned objects (objects in a circular ref loop).
What is &h02??
That’s just the code for the specific error that the compiler found and is usually not very interesting. The important thing is that it’s saying you have a syntax error in line 73. What is your line 73?
–Mark
Hi RokuMartin,
Since that last debugger I did some other changes etc. But now it gives me more errors in more lines…lol. In line 44 I only have:
while true
But it says I have a syntax error. Can an extra space or return cause a syntax error?
Thank you.
Not usually. in cases like this, check to see if there is a missing end while, or perhaps a missing end if, end sub, end function, something like that, missing up above or below the while true. If you have an opening statement without a closing statement, it throws everything off, so you need to track it down.
Most helpful thing is to keep backup copies of each edit you make, for example in JEdit, which I use, I have it keep a copy of the last 200 saves, so every time I save there is a copy of before and after.
Hi Joel,
I downloaded jedit on your suggestion from before.
I discovered the post I left here was actually pertaining to another item I had in the debugger and was working on today. Regardless, I’ll check that suggestion you made to see what I am missing.
The adurl, I left you a note just a moment ago. Can’t figure out what the problem is with it. I made an image and its on the server. debugger was saying I had syntax errors in it. Checked many times but to no avail.
I’ll have to keep trying. The display ads and the pre-roll video have to work and I’ll keep tweaking till it comes together. The help you provide and people I have met in the forum are a big help.
Thank you.
Finally…I have the ad showing up on the posterscreen.
Now to figure out how to use a php script to randomly change the ad each time it loads and one major part will have been completed.
Any suggestions from anyone here on using php and where to place it? Is it a file that gets added to the server side?
Thank you.
PHP is a file that you create on your server, and isn’t too different from a regular web page, in fact you can mix php in with html:
<html>
<title>this is my web page</title>
<body>
this is the body of my web page<br>
<?
echo 'this is the php section';
?>
<br>
this is more of the body of my web page
</body>
</html>
or you can just create a php file like my.php and have the contents like this:
<?
echo 'this is my php page';
?>
so if you were going to install an ad serving php program on your web server, you would probably just create a folder and upload the program files into that folder, then you would just point SetAdURL at the ad serving file like:
screen.setadurl(“http://myserver.com/adverts/myad.php”,“http://myserver.com/adverts/myad.php”)
and it your ad server would automatically choose the ad graphics to display. It might need to be modified a bit so it just serves the graphics and nothing more.
Usually this would integrate with a database on your server so you would need to give the script the username and password to your database when you set it up.
Some ad rotation php scripts don’t need a database, you just dump the ad images into a folder with the script.
I located several php ad rotation scripts. I’m going with one without database for now. I do plan for it to be more extensive later so I can have statistics on the ad views.
I’ll give it a try.
Thank you.