print "ok well that didn't blow up so now do that parsing stuff"
if m.xmlTracklist.Parse(m.xferResult)
print "parse is true"
counter=0
print "counter="+counter.ToStr()
For Each track in m.xmlTrackList.track
?"************xmlcheck***************"
xmlcheck=m.xmlTrackList.track.GetNamedElements("stream-url").[counter].GetText()
?"***********************************"
if xmlcheck <> invalid and xmlcheck <> "" then 'doesn't ever get this far on the last iteration because xmlcheck crashes
?"xml check success"
GetTrackSet(counter, track) ' this function is where it would die
print m.TrackTitle+", "+m.TrackURL
posterlist.push(CreatePosterItems())
counter=counter+1
print "counter="+counter.ToStr()
else
?"xmlcheck failed"
end if
Next
End If
return posterlist
end function
function getTrackSet(counter as integer, track as object) as object
....
m.TrackURL = m.xmlTrackList.track.GetNamedElements("stream-url").[counter].GetText()+m.ckey 'this line would blow up if it didn't blow up in the calling function
....
end function
If m.xmlTracklist.Parse(m.xferResult) Then
print "parse is true"
counter=0
print "counter="+counter.ToStr()
For Each track in m.xmlTrackList.track
xmlStreamUrls = track.GetNamedElements("stream-url")
If xmlstreamUrl <> invalid And xmlStreamUrls.Count() > 0 Then
xmlcheck = xmlStreamUrls[ 0 ].GetText()
if xmlcheck <> invalid and xmlcheck <> "" then 'doesn't ever get this far on the last iteration because xmlcheck crashes
?"xml check success"
GetTrackSet(counter, track) ' this function is where it would die
print m.TrackTitle+", "+m.TrackURL
posterlist.push(CreatePosterItems())
counter=counter+1
print "counter="+counter.ToStr()
else
?"xmlcheck failed"
end if
End If
Next
End If
"TheEndless" wrote:
Also, why aren't you passing the stream url to the getTrackSet function? Your code is inefficiently grabbing an roXMLList every time you call to those xml nodes, which isn't necessary, since you looping through them to begin with. It seems to me, the [counter] part you have in there now is only working by chance. It could easily get out of sync if any one of the elements didn't have a "stream-url" node.
'***********************************************
'get searched for tracks
'***********************************************
function getsearchTracks(ofs as integer, lim as integer, querystring as string) as object
posterlist=createobject("roarray",1,true)
m.audioplayer.clearcontent()
print "searchtracks="+querystring
offset=ofs.tostr()
print "offset="+offset
limit=lim.tostr()
print "limit="+limit
print "assign url all that gnarly stuff for the query"
m.url=m.api+"/tracks.xml?q="+querystring+"&"+mid(m.ckey,2)+"&limit="+lim.tostr()+"&ofs="+ofs.tostr()
print "now set xfer url"
m.xfer.setURL(m.url)
print "now do the get to string thing"
m.xferResult= m.xfer.GetToString()
print "ok, skip printing result of transfer, this may be where it blows up?"
'print "transfer-result"+m.xferResult
print "ok well that didn't blow up so now do that parsing stuff"
if m.xmlTracklist.Parse(m.xferResult)
print "parse is true blue"
counter=0
print "counter="+counter.ToStr()
For Each track in m.xmlTrackList.track
?"************xmlcheck***************"
xmlcheck=m.xmlTrackList.track.GetNamedElements("stream-url").[counter].GetText()
?"***********************************"
if xmlcheck <> invalid and xmlcheck <> "" then
?"xml check success"
GetTrackSet(counter, track)
print m.TrackTitle+", "+m.TrackURL
posterlist.push(CreatePosterItems())
counter=counter+1
print "counter="+counter.ToStr()
else
?"xmlcheck failed"
end if
Next
End If
return posterlist
end function
"TheEndless" wrote:
I really don't understand that [counter] part. And your outer look doesn't makes sense either, since you're not using "track". Try this instead...
function getTrackSet(counter as integer, track as object) as object
m.TrackURL = m.xmlTrackList.track.GetNamedElements("stream-url").[counter].GetText()+m.ckey
m.TrackGenre=m.xmlTrackList.track.GetNamedElements("genre").[counter].GetText()
m.TrackDescription = m.xmlTrackList.track.GetNamedElements("description").[counter].GetText()
m.TrackCreated=m.xmlTrackList.track.GetNamedElements("created-at").[counter].GetText()
m.WaveformURL=m.xmlTracklist.track.GetNamedElements("waveform-url").[counter].GetText()+m.ckey
m.ArtworkURL=m.xmlTrackList.track.GetNamedElements("artwork-url").[counter].GetText()
if m.ArtworkURL="" then
m.ArtworkURL="pkg:/images/sc-roku-poster.png"
else
m.artworkURL=m.ArtworkURL+m.ckey
end if
print m.ArtworkURL
print type(m.artworkURL)
m.song.url = m.TrackURL+m.ckey
m.song.StreamFormat="mp3"
m.audioplayer.addcontent(m.song)
return m.song
End Function
m.TrackURL = m.xmlTrackList.track.GetNamedElements("stream-url").[counter].GetText()+m.ckey
m.TrackURL = track.GetNamedElements("stream-url").GetText()+m.ckey
<tracklist>
<track>
<stream-url>blah 1</stream-url>
<genre>genre 1</genre>
<description>description 1</description>
</track>
<track>
<stream-url>blah 2</stream-url>
<description>description 2</description>
</track>
<track>
<stream-url>blah 3</stream-url>
<genre>genre 3</genre>
<description>description 1</description>
</track>
</tracklist>
m.xferResult= m.xfer.GetToString()
if m.xmlTracklist.Parse(m.xferResult)
For Each track in m.xmltracklist.track
taglist=track.extracttaglist() 'hypothetical function that I don't know how to write
xmlcheck=track.validate(taglist) 'hypothetical function that I'm not quite sure how to write