Link to home
Start Free TrialLog in
Avatar of ed987
ed987

asked on

text parsing

i'm looking for actionscript that loads url containing text like this:

#EXTM3U
#EXTINF:length1,title1
url1.mp3
#EXTINF:length2,title2
url2.mp3
#EXTINF:length3,title3
url3.mp3

and makes this on each entry

list += "<track><location>"+url+"</location><annotation>"+title+"</annotation><duration>"+length*1000+"</duration></track>"
ASKER CERTIFIED SOLUTION
Avatar of Dushan Silva
Dushan Silva
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of sam85281
sam85281

First, is there a reason you can't just put all that in an xml file and load that already ready to go?

If so, at minimum you will need to add a variable indicator to the biginning.
i.e.
myTracks=#EXTM3U
#EXTINF:length1,title1
url1.mp3
#EXTINF:length2,title2
url2.mp3
#EXTINF:length3,title3
url3.mp3

Also if you can change the format would be better to sperate the url with a comma like you do with title and length.
i.e.
myTracks=#EXTM3U
#EXTINF:length1,title1,url1.mp3
#EXTINF:length2,title2,url2.mp3
#EXTINF:length3,title3,url3.mp3

Best would be to make an xml file instead of a text file.

Let us know what your formatting limitations are and we can go from there.

-Sam
Avatar of ed987

ASKER

* is there a reason you can't just put all that in an xml file

yes, files are generated by player.

well, i assume solution goes sth along these lines
nn=0;
n=str.indexOf("\n");if(n<0)return;
while((n=str.indexOf("\n",n))
{
   x.substr();
   aa=x.split(':');
   if(nn%3==1)..
   if(nn%3==2)..
   ++nn;
}
Well the problem is going to be that flash can't do ANYTHING with that text file unless you AT LEAST have the ability to add a variable in front of it like:

myTracks=#EXTM3U
#EXTINF:length1,title1
url1.mp3
#EXTINF:length2,title2
url2.mp3
#EXTINF:length3,title3
url3.mp3

Without that, flash loads nothing.

If you have PHP, VB, other server side language available you can use a php file to append that variable to the front of your file and then feed that into flash.

Do you have a server language available on your server?

-Sam
Avatar of ed987

ASKER

* Without that, flash loads nothing.

it does, checked flash 6,7,8

i wrote the rest of actionscript myself :\
giving 400 points to Dushan1, 100 just want to keep !