Roku Developer Program

Developers and content creators—a complete solution for growing an audience directly.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
squirreltown
Level 9

Get Title from XML

Modified DevientArt from the SDK

Trying to get Titles to appear on button

slideshow.AddButton(btn_bookmark, photo.GetTitle())

This returns the last image title in the XML file no matter how long the list, not for each image as it goes. The picture part of the slideshow works fine.
So if the XML list is 60 items long - image #1 will show title #60 and image #2 will show title #60 etc..

here is GetTitle defined in "mediarsstoolkit.brs

Function newPhotoFromXML(http As Object, xml As Object) As Object
photo = {http:http, xml:xml, GetURLSmiley TongueGetURL}
photo.GetTitle=function():return m.xml.title.GetText():end function
return photo
End Function
Kinetics Screensavers
0 Kudos
9 REPLIES 9\
RokuChris
Roku Employee
Roku Employee

Re: Get Title from XML

Maybe you need to be referencing the local variable called xml instead of the global variable called m.xml
0 Kudos
squirreltown
Level 9

Re: Get Title from XML

"RokuChris" wrote:
Maybe you need to be referencing the local variable called xml instead of the global variable called m.xml


Im not successful in trying that but it doesnt mean you arent right.

The thing is when you watch the debugger in the terminal, it shows all the titles loading when the Sub starts, it even lists them twice photo title = and after PRELOAD TITLE.

Since i am getting one title to show (the last One) i must not be asking the place where they are cached?
Kinetics Screensavers
0 Kudos
squirreltown
Level 9

Re: Get Title from XML

"squirreltown" wrote:
"RokuChris" wrote:
Maybe you need to be referencing the local variable called xml instead of the global variable called m.xml


Ok I'm not able to figure out how to do that. I've tried changing it or adding it and am not getting it to work.

The thing about this is that DevientArt is in the Roku SDK as an example. So the example has all this code in it which seems close to spiting out titles when needed but just is missing one thing which i cant see what it is. So my question to people with Roku in their name would be Shouldn't this work since its in the SDK? Is it a test? Why put all that title-related code in and then not finish it?

thanks
Kinetics Screensavers
0 Kudos
RokuMarkn
Level 8

Re: Get Title from XML

I think you need to provide a little more context about what changes you've made. Looking at the deviantart example, there is a loop that runs through all the photos which prints each title. These titles are correct for me; I assume the same is true for you. Is that the place where you're calling AddButton? I suspect you're calling AddButton somewhere after this loop, when it has finished iterating the photos, so "photo" is no longer valid -- it still refers to the last one in the list.

--Mark
0 Kudos
squirreltown
Level 9

Re: Get Title from XML

"RokuMarkn" wrote:
I think you need to provide a little more context about what changes you've made. Looking at the deviantart example, there is a loop that runs through all the photos which prints each title. These titles are correct for me; I assume the same is true for you. Is that the place where you're calling AddButton? I suspect you're calling AddButton somewhere after this loop, when it has finished iterating the photos, so "photo" is no longer valid -- it still refers to the last one in the list.

--Mark



Thank you! For this question I take the stock SDK DevientArt example and make two changes to mediasrrtoolkit.brs- to uncomment an existing button and add the GetTitle function to it instead of text "bookmark".

slideshow.AddButton(btn_bookmark, photo.GetTitle())

I also uncomment slideshow.ClearButtons() at the end of the same block.



This returns the title of the last item in the XML list, shows it on the button. Frankly, buttons are not what i want - i would like it in info from the * button but no point in trying to do that if this title thing doesn't work, just using the button cause i need to see the text print somewhere.

I understand in principle that this could be outside the loop as you can see the loop load in the terminal, but the URLs are obviously being fed as needed i just dont see why the titles aren't following
Kinetics Screensavers
0 Kudos
RokuMarkn
Level 8

Re: Get Title from XML

Hm, I didn't understand your last sentence at all, but let me try again. The loop in lines 103-112 is going through each photo and printing its title. If you want a button per title, that's the place where you need to create the button. If you're not trying to make one button per title then I don't understand what you're trying to do so you'll have to explain it. Maybe you want a button to show the currently playing item? That's completely different -- you'd have to extract each title from the list when you get the isPlaybackPosition message for that item.

--Mark
0 Kudos
squirreltown
Level 9

Re: Get Title from XML

"RokuMarkn" wrote:
Hm, I didn't understand your last sentence at all, but let me try again. The loop in lines 103-112 is going through each photo and printing its title. If you want a button per title, that's the place where you need to create the button. If you're not trying to make one button per title then I don't understand what you're trying to do so you'll have to explain it. Maybe you want a button to show the currently playing item? That's completely different -- you'd have to extract each title from the list when you get the isPlaybackPosition message for that item.

--Mark


Precisely - I want to show the title of the currently playing image in the slideshow - Which i apologize if i am dense seems to me to be the purpose of a title getting system at all. So - I need to put the GetTitle inside the loop for each item? Is the reason this function is not visible in the stock SDK ( you have to make it show) means it wasn't finished so it was left out even though the guts are there? Just curious since there seems to be some effort writing in an obvious feature but left it out of the example.
Kinetics Screensavers
0 Kudos
RokuMarkn
Level 8

Re: Get Title from XML

In that case, as I said, you should extract the title when you get the PlaybackPosition event, save it in a variable, and use it for your button later. For example, add

curr_photo = photolist[onscreenphoto]

in the PlaybackPosition handler, and then call

slideshow.AddButton(btn_bookmark, curr_photo.GetTitle())

to add your button.

--Mark
0 Kudos
squirreltown
Level 9

Re: Get Title from XML

"RokuMarkn" wrote:
In that case, as I said, you should extract the title when you get the PlaybackPosition event, save it in a variable, and use it for your button later. For example, add

curr_photo = photolist[onscreenphoto]

in the PlaybackPosition handler, and then call

slideshow.AddButton(btn_bookmark, curr_photo.GetTitle())

to add your button.

--Mark


Thank You! That worked , really appreciate it , I wouldn't have found that.
Kinetics Screensavers
0 Kudos