Your Digital Media Has Never Looked So Good

 
belltown
Posts: 1465
Joined: Thu Dec 09, 2010 1:43 pm
Contact:

Re: setadurl question

Sat Mar 03, 2012 2:32 pm

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.
https://github.com/belltown/
 
newchannel
Topic Author
Posts: 510
Joined: Tue Aug 02, 2011 2:09 pm

Re: setadurl question

Sat Mar 03, 2012 2:39 pm

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
 
belltown
Posts: 1465
Joined: Thu Dec 09, 2010 1:43 pm
Contact:

Re: setadurl question

Sat Mar 03, 2012 2:46 pm

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.
https://github.com/belltown/
 
newchannel
Topic Author
Posts: 510
Joined: Tue Aug 02, 2011 2:09 pm

Re: setadurl question

Sat Mar 03, 2012 2:59 pm

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
 
belltown
Posts: 1465
Joined: Thu Dec 09, 2010 1:43 pm
Contact:

Re: setadurl question

Sat Mar 03, 2012 3:32 pm

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.
https://github.com/belltown/
 
newchannel
Topic Author
Posts: 510
Joined: Tue Aug 02, 2011 2:09 pm

Re: setadurl question

Sat Mar 03, 2012 5:08 pm

Thank you, I will try that tonight!
http://www.victoryNOWfilmsandtv.com
 
newchannel
Topic Author
Posts: 510
Joined: Tue Aug 02, 2011 2:09 pm

Re: setadurl question

Sat Mar 03, 2012 6:13 pm

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
 
belltown
Posts: 1465
Joined: Thu Dec 09, 2010 1:43 pm
Contact:

Re: setadurl question

Sat Mar 03, 2012 6:39 pm

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).
https://github.com/belltown/
 
bandal
Posts: 260
Joined: Sat Oct 15, 2011 2:17 pm

Re: setadurl question

Sat Mar 03, 2012 7:32 pm

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
 
newchannel
Topic Author
Posts: 510
Joined: Tue Aug 02, 2011 2:09 pm

Re: setadurl question

Sat Mar 03, 2012 9:10 pm

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
 
bandal
Posts: 260
Joined: Sat Oct 15, 2011 2:17 pm

Re: setadurl question

Sat Mar 03, 2012 9:24 pm

Maybe it is this part that is missing:
.
.
.
screen.SetAdURL(url, url)
screen.SetListNames(getCategoryList(category))
screen.SetContentList(getShowsForCategoryItem(category, m.curCategory))
screen.SetAdDisplayMode("scale-to-fit")
screen.SetAdSelectable(true)
screen.Show()
 
newchannel
Topic Author
Posts: 510
Joined: Tue Aug 02, 2011 2:09 pm

Re: setadurl question

Sat Mar 03, 2012 9:48 pm

Hi bandal,

I just added it again to the posterscreen.brs. zipped, loaded to device, no images.

I took the url of pasted into browser and it shows. hit F5 and it changes. I copied and pasted it from the browser and then put in posterscreen.brs (the link to the php file).

Oh well, it's a learning experience...lol

I'll see what else I can come up with. Only thing I can think of is the posterscreen.brs may need to be changed like I sent you info on in the email.

Thanks to all that are helping.
http://www.victoryNOWfilmsandtv.com
 
belltown
Posts: 1465
Joined: Thu Dec 09, 2010 1:43 pm
Contact:

Re: setadurl question

Sat Mar 03, 2012 11:11 pm

It could be that the request for the php script is failing. Once way to track that down would be to issue an asynchronous request, which would allow you to examine the http response code.

Put the following function before the showPosterScreenFunction:

Function getAdUrl (scriptUrl As String, timeout As Integer) As Object

   ut = CreateObject ("roUrlTransfer")
   port = CreateObject ("roMessagePort")
   ut.SetPort (port)
   ut.SetUrl (scriptUrl)

   result = ut.AsyncGetToString ()
   If result
      While True
         msg = Wait (timeout, port)
         If Type (msg) = "roUrlEvent"
            Print "AsyncGetToString: msg.GetResponseCode () = " + msg.GetResponseCode ().ToStr () + ". msg.GetFailureReason () = " + msg.GetFailureReason ()
            If msg.GetResponseCode () = 200
               Return msg.GetString ()
            Else
               Return Invalid
            Endif
         Else If Type (msg) = "Invalid"
            Print "AsyncGetToString: timeout"
            ut.AsyncCancel ()
            Return Invalid
         Else
            Print "AsyncGetToString: Unknown event: " + Type (msg)
         Endif
      End While
   Endif

   Return Invalid

End Function


Then replace this code:

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


with this code:

      url = getAdUrl ("http://xxxxx.net/xxx/adverts/rotateads.php", 0)
      if url <> Invalid
         screen.SetAdURL(url, url)
      else
         print "Unable to retrieve ad url"
      endif

The check the debugger output for a message that starts with "AsyncGetToString: msg.GetResponseCode () =" That will tell you the response from the server. It should be 200 (success). Anything else will indicate some kind of error condition.
https://github.com/belltown/
 
newchannel
Topic Author
Posts: 510
Joined: Tue Aug 02, 2011 2:09 pm

Re: setadurl question

Sun Mar 04, 2012 10:50 am

Hi belltown,

I added the code you suggested and zipped and received the 200. Thanks for much for providing that code. I would not have know how to do that if you had not supplied it. That is a wonderful tool you shared.

After changing out my posterscreen.brs for another one, I was able to show ads and make them clickable to play video. Thanks bandal for helping with this portion. It works to show your ads and play my video link. If I change the url of the ad image to my own, the images again disappear. I once again went to the browser to test the url and it works only in the browser.

I've been checking the image urls in browser and the same link shows the actual image in the browser.

Anyway, that's the update. I'm just wondering if it has something to do with my server. I'm looking for a place to move my files to since the present location was just for temporary place until I could get more familiar with the build. i have a copy of my files from the server using ftp in case they shut me down. I had thought about that before and been keeping backups of my files from the server just in case.

Might be a good idea for me to test using a different server and see if my images will show. If they do then that will take care of the problem.

belltown and bandal...you both have gone beyond the norm to assist. Thanks so much again and thanks to all in the forum that have been also helping me along the way.

Best Regards.
http://www.victoryNOWfilmsandtv.com
 
belltown
Posts: 1465
Joined: Thu Dec 09, 2010 1:43 pm
Contact:

Re: setadurl question

Sun Mar 04, 2012 3:14 pm

You could also try having your rotateads.php script return some different image urls for testing purposes.

I know that the following image urls work:

http://blog.roku.com/wp-content/uploads ... u-rear.jpg

and

http://blog.roku.com/wp-content/uploads ... /roku6.jpg

If it works then that means that your Roku channel code and your rotateads.php script are functioning correctly, and the problem lies with your server trying to serve up the images to your Roku, or a problem with the image files themselves that would prevent the Roku from displaying them.

It could be that your server has hotlink protection enabled, which is designed to prevent other web sites to link to your images. There should be a way you can turn this off for your server. If you're using cPanel there should be a 'Hotlink Protection' icon under 'Security'. When you click on it you should see a 'Disable' button that you can click to turn off hotlink protection.
https://github.com/belltown/

Who is online

Users browsing this forum: No registered users and 4 guests