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: 
dynamitemedia
Binge Watcher

here is a sample of xml for audio App

this may not be the best sample and sure it can be cleaned up a bit as well as for more error handling

here is what the xml should look like:

<songs>
<song>
<title>song title 1</title>
<url>song url 1</url>
<author>song author 1</title>
<desc>description song 1</desc>
<fmt>format of song (mp3)</fmt>
<image>song image url 1</image>
</song
<song>
<title>song title 2</title>
<url>song url 2</url>
<author>song author 2</title>
<desc>description song 2</desc>
<fmt>format of song (mp3)</fmt>
<image>song image url 2</image>
</song
</songs>


and this is what i used to populate the poster screen, again this is for the audio app and i used the mp3.brs
Function CreateSongList() as Object
aa = CreateObject("roAssociativeArray")
aa.posteritems = CreateObject("roArray", 10, true)

m.UrlBase = "http://XXXX.com/roku"
m.UrlGetMp3Info = m.UrlBase + "/xml/mp3Playlist.php"
http = NewHttp(m.UrlGetMp3Info)

rsp = http.Http.GetToString()
xml = CreateObject("roXMLElement")

if not xml.Parse(rsp) then
print "Can't parse response"
ShowConnectionFailed()
return ""
end if

if xml.GetName() <> "songs"
Dbg("Bad response: ", xml.GetName())
ShowConnectionFailed()
return ""
end if

if islist(xml.GetBody()) = false then
Dbg("No Song information available")
ShowConnectionFailed()
return ""
end if

For Each song in xml.song
'initialize variables with empty strings, just in case they're missing in the XML
title = ""
url = ""
image = ""
fmt = ""
desc = ""
author = ""

title = song.title.GetText()
url = song.url.GetText()
author = song.author.GetText()
image = song.image.GetText()
fmt = song.fmt.GetText()
desc = song.desc.GetText()

song = CreateSong(title, desc, author, fmt, url, image)
aa.posteritems.push(song)

Next

return aa

End Function

Sub DoMp3(from as string)
'Put up poster screen to pick a song to play
SongList = CreateSongList()
Pscreen = StartPosterScreen(SongList, from, "whatever you want here to display on screen")

while true
song = Pscreen.GetSelection(0)
if song = -1 exit while
Show_Audio_Screen(songlist.posteritems[song],"whatever you want here to display on screen")
end while
End Sub


Hope that helps someone else, I got help from Endless and Jbrave on this thread

http://forums.roku.com/viewtopic.php?f=34&t=31901&p=211219#p211219
Twitter: iptvmyway facebook: iptvmyay
Channels: Warriors of War, Go Fight Live, Heading Outdoorz, IPTVmyway
0 Kudos
3 REPLIES 3
TheEndless
Channel Surfer

Re: here is a sample of xml for audio App

dynamite,
You don't need the nested For...Next loop in that example. You only need that if you actually want to walk through the child elements. Since you're grabbing them specifically via the song element (i.e., song.title.GetText()), you don't need to wrap them in a loop. In fact, you're actually calling those lines six times for each song right now, which is just additional overhead you don't need.
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
dynamitemedia
Binge Watcher

Re: here is a sample of xml for audio App

Thanks I changed that !
Twitter: iptvmyway facebook: iptvmyay
Channels: Warriors of War, Go Fight Live, Heading Outdoorz, IPTVmyway
0 Kudos
dynamitemedia
Binge Watcher

Re: here is a sample of xml for audio App

Ok endless i have tried re using this example elsewhere and its not working, one thing is i am trying to use the xml that all the other feeds use in the video player example
the xml is like this

<feed>
<item sdImg="http://xxxx.com/imagees/videos/1993.jpg" hdImg="http://xxxx.com/images/videos/1993.jpg">
<title>Hernandez</title>
<contentId>10001</contentId>
<contentType>Fight</contentType>
<contentQuality>SD</contentQuality>
<media>
<streamFormat>mp4</streamFormat>
<streamQuality>SD</streamQuality>
<streamBitrate>700</streamBitrate>
<streamUrl>http://xxxx.com/roku/video/1993.mp4</streamUrl>
</media>
<synopsis>Leo Hernandez</synopsis>
<genres>Clip</genres>
<runtime>703</runtime>
</item>


<item sdImg="http://xxxx.com/imagees/videos/1994.jpg" hdImg="http://xxxx.com/images/videos/1994.jpg">
<title>Leo</title>
<contentId>10002</contentId>
<contentType>Fight</contentType>
<contentQuality>SD</contentQuality>
<media>
<streamFormat>mp4</streamFormat>
<streamQuality>SD</streamQuality>
<streamBitrate>700</streamBitrate>
<streamUrl>http://xxxx.com/roku/video/1994.mp4</streamUrl>
</media>
<synopsis>Leo</synopsis>
<genres>Clip</genres>
<runtime>703</runtime>
</item>



</feed>



here is what is what i have now and its not showing up anything

For Each item in xml.item
'initialize variables with empty strings, just in case they're missing in the XML
title = ""
url = ""
image = ""
fmt = ""
desc = ""
author = ""

title = item.title.GetText()
author = item.genres.GetText()
image = item.image.GetText()
desc = item.description.GetText()

song = CreateSong(title, desc, author, fmt, url, image)
showList.Push(song)


but the reason i need to change this i do not want to have to go in and change all the xml i already have done for the video and do it differently for the audio
Twitter: iptvmyway facebook: iptvmyay
Channels: Warriors of War, Go Fight Live, Heading Outdoorz, IPTVmyway
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.