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: 
belltown
Roku Guru

Re: setadurl question

"newchannel" wrote:
Hi belltown,

I did a re-do. Now what happens is no syntax error. Thank you.

But instead of getting the ad image within my browser, it gives me the actually the typed words: "http://xxxxx.net/xxx.xxxxxxx.jpg

instead of the image graphic.

That's the correct behavior. The script returns the URL for the image you want to display, not the image itself. When you run it from your web browser you are testing that the correct url is returned. When you call the script from your SetAdUrl BrightScript code, that's the url for the ad that should be displayed.

The ad can be wherever you want it to be. If it's on another website you can specify http://otherwebsite.com/image.jpg. If it's on your own web server it can be http://myserver.net/image.jpg if the image file is in your public_html directory or http://myserver.net/adverts/image.jpg if the image is in the "adverts" folder under your public_html directory, and if the image file is in your channel's "image" folder you can use pkg:/images/image.jpg. However, if the ads were in your channel package there wouldn't be any point running an external PHP script to figure out which ad to display. You'd most likely want to store them on your server so you can change them without having to re-package your channel.
0 Kudos
newchannel
Roku Guru

Re: setadurl question

Okay, thank you so very much. Going to continue and see if they change on the device.

I appreciate your help! Will test and post back.
http://www.victoryNOWfilmsandtv.com
0 Kudos
belltown
Roku Guru

Re: setadurl question

"newchannel" wrote:
Okay, thank you so very much. Going to continue and see if they change on the device.

I appreciate your help! Will test and post back.

One more thing you should test before trying it out on the device is typing the URL that the script returns into your browser's address bar (copy it from the screen and paste into address bar). You should then see the image displayed in your web browser. If not then it's most likely not going to work on your Roku either.
0 Kudos
newchannel
Roku Guru

Re: setadurl question

After correcting the posterscreen.brs I zipped and loaded to the device. The images are not displaying. I am able to get one single image to display without using the php script but using the php no images display.

I used my browser to test the link of each image. Each image graphic displayed in browser. Not sure why on device it doesn't show images unless I have the setadurl in the wrong place. I have pasted here the posterscreen.brs I am using in case you get time to review.

Best Regards.





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

screen.SetAdURL("http://www.xxxx.net/xxx/adverts/rotateads.php", "http://www.xxxx.net/xxx/adverts/rotateads.php")
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
http://www.victoryNOWfilmsandtv.com
0 Kudos
belltown
Roku Guru

Re: setadurl question

Change this:


screen.SetAdURL("http://www.xxxx.net/xxx/adverts/rotateads.php", "http://www.xxxx.net/xxx/adverts/rotateads.php")


To this:


ut = CreateObject ("roUrlTransfer")
ut.SetUrl ("http://www.xxxx.net/xxx/adverts/rotateads.php")
url = ut.GetToString ()
screen.SetAdURL(url, url)


It looks like SetAdUrl requires the name of an image file and doesn't work if you pass a script that returns the name of an image file.
0 Kudos
newchannel
Roku Guru

Re: setadurl question

Thank you, I will try that tonight!
http://www.victoryNOWfilmsandtv.com
0 Kudos
newchannel
Roku Guru

Re: setadurl question

I changed out the posterscreen.brs code snippet and zipped to device. But the display ads are not showing. Pretty strange. Do I have the code in the right location within the rest of the code?

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

ut = CreateObject ("roUrlTransfer")
ut.SetUrl ("http://www.xxxx.net/xxx/adverts/rotateads.php")
url = ut.GetToString ()
screen.SetAdURL(url, url)
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
http://www.victoryNOWfilmsandtv.com
0 Kudos
belltown
Roku Guru

Re: setadurl question

That code works just fine on my Roku. Double-check you have saved all the edits to the code you changed and packaged it and side-loaded it to your Roku correctly. You can try adding in an extra print statement after the call to SetAdUrl for debugging purposes to see if the code you added is being executed. Double-check that you have the correct URL for the PHP script (copy it and paste into your web browser to see if you're still getting the correct image Url, then copy and paste that image Url into your browser address bar to check that you can still display the image correctly).
0 Kudos
bandal
Visitor

Re: setadurl question

I have followed along and my ads rotate just fine.

Since I want clickable ads to play content, I had before in my source directory just 1 .mp4 to play. My file playBanner.brs contains code that plays, but now how to make it a php file to call more than 1 .mp4 or the correct banner to .mp4 file versus the code I have now below?

Sub PlayAdVideo()
videoScreen = CreateObject("roVideoScreen")
port = CreateObject("roMessagePort")
videoScreen.SetMessagePort(port)
episode = {
Stream: { Url: "http://www.xxxxx.tv/roku/banner/testbanner.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
0 Kudos
newchannel
Roku Guru

Re: setadurl question

I don't know. Pretty strange. The ads dissappear completely using the code. But with just the old way without php and using url's, they show up. Eventually it will work. I've checked the posterscreen.brs and pasted here what is on the device. I will keep checking it to see what i can come up with.

I appreciate all of your help today belltown!


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


ut = CreateObject ("roUrlTransfer")
ut.SetUrl ("http://xxxxx.net/xxx/adverts/rotateads.php")
url = ut.GetToString ()
screen.SetAdURL(url, url)



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
http://www.victoryNOWfilmsandtv.com
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.