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

Banner ADS

Hi developers.
I have a question about the Banner ADS, I follow your script on the forum and few works very well but I have a problem to up to date the graphic, for example if today I want to have Adidas as sponsor and tomorrow i would like have Nike as sponsor I can't.
I changed the jpeg from my URL directory but Roku NOT automatically change the graphic still again on the old graphic, someone do you know why?
thank you in advance
0 Kudos
7 REPLIES 7
RokuJoel
Binge Watcher

Re: Banner ADS

add a random string to your url kinda like this:

url="http://myserver.com/image.jpg"
imgurl=url+"?rand="+rnd(10000).tostr()


this should "bust" the cache and force download of the new image. You might want to use a flag file on your server to turn this on and off:


xfer=createobject("rourltransfer")
flagfile=("http://myserver.com/flag.txt")
xfer.seturl(flagfile)
flag=xfer.gettostring()
if flag="true" then
imgurl=url+"?rand="+rnd(10000).tostr()
else if flagfile="false"
imgurl=url
end if


so you don't waste bandwidth reloading the same graphic over and over, until you actually need to change the image.

- Joel
0 Kudos
IRoad
Visitor

Re: Banner ADS

Hi Joel,
I tried for suggestion but I am confuse about where put your script, I believe on POSTER SCREEN, but not it appear.

Follow a part of the script were i put it

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

xfer=createobject("rourltransfer")
flagfile=("http://xxxxxxxxxxxx.cloudfront.net/vodrokubanner/540x60.jpg")
xfer.seturl(flagfile)
flag=xfer.gettostring()
if flag="true" then
imgurl=url+"?rand="+rnd(10000).tostr()
else if flagfile="false"
imgurl=url
end if

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
0 Kudos
RokuJoel
Binge Watcher

Re: Banner ADS

Hi,


the flagfile is just a text file you would set to "true" or "false" to force an update of your image on the devices.

you need also to have an SD sized ad and an HD sized ad, and you use SetAdURL(SDAdURL,HDAdURL).

so:

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

xfer=createobject("rourltransfer")
flagfile=("http://xxxxxxxxxxxx.cloudfront.net/vodrokubanner/flag.txt")
SDURL="http://xxxxxxxxxxxx.cloudfront.net/vodrokubanner/540x60.jpg"
HDURL="http://xxxxxxxxxxxx.cloudfront.net/vodrokubanner/728x90.jpg"
xfer.seturl(flagfile)
flag=xfer.gettostring()
if flag="true" then
SDAdURL=SDURL+"?rand="+rnd(10000).tostr()
HDAdURL=HDURL+"?rand="+rnd(10000).tostr()
else if flagfile="false"
SDAdURL=SDURL
HDAdURL=HDURL
end if

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.SetAdURL(SDAdURL,HDAdURL)

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


By the way, if when you post code to the forum, please select the code and click the Code button to format it as code.

- Joel
0 Kudos
TheEndless
Channel Surfer

Re: Banner ADS

"RokuJoel" wrote:
the flagfile is just a text file you would set to "true" or "false" to force an update of your image on the devices.

How would he know when to change the flag file back to false? It'd probably make more sense to set the date of the last update in that file, then store that date on the box to compare against. Or, better yet, if he's loading that file anyway, why not just put the url of the images in that file, and update that when a new ad is available.
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
RokuJoel
Binge Watcher

Re: Banner ADS

Those are probably better solutions.

- Joel
0 Kudos
IRoad
Visitor

Re: Banner ADS

Thanks RokuJoel
0 Kudos
IRoad
Visitor

Re: Banner ADS

Hi,
in the flag.txt i need just to write "true" or I need write more information inside the .txt file....
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.