Audio: Reading Internet "Playlist" and outputting audio

Reply

Join Date: Dec 2004
Posts: 27
Reputation: Frank0051 is an unknown quantity at this point 
Solved Threads: 0
Frank0051 Frank0051 is offline Offline
Light Poster

Audio: Reading Internet "Playlist" and outputting audio

 
0
  #1
Nov 25th, 2005
I been working on this little program that would allow the user to reference this custom playlist file. The playlist file is a simple text file with a list of music files on a URL:

  1. http://www.whatever.com/a.wav
  2. http://www.whatever.com/b.wav
  3. etc...

Basically what the program would do is ask the user for the playlist file, then it would store that in a String and open the text file (which is stored on a URL) in a URL object. What I want to try and do is read a line of the URL file and pass that String onto an AudioInputStream object (or any stream that could be read, looped, and written to a sourceDataLine). Basically I can read a URL of a single file (whatever.wav) off an internet site but I cannot read in the custom playlist I'm going for. This is the loop I'm using for the audiostream:

  1. audioInputStream = AudioSystem.getAudioInputStream(audio); //(audio is the file I want to read in; however I cannot figure out how to read a line of a URL object to a String to actually file the audiovariable)
  2. audioFormat = audioInputStream.getFormat();
  3.  
  4. DataLine.Info dataLineInfo = //Output line to hardware
  5. new DataLine.Info(SourceDataLine.class,audioFormat);
  6.  
  7. if(debug==1)
  8. System.out.println("Loading to Mixer DataLine");
  9.  
  10. sourceDataLine = (SourceDataLine)AudioSystem.getLine(dataLineInfo);
  11. sourceDataLine.open(audioFormat);
  12. sourceDataLine.start();
  13.  
  14.  
  15. int cnt;
  16. while((cnt = audioInputStream.read(tempBuffer,0,tempBuffer.length)) != -1){
  17. if(cnt > 0){
  18. if(debug==1)
  19. System.out.println("Writing Stream to Internal Buffer");
  20. sourceDataLine.write(tempBuffer, 0, cnt);
  21. }
  22. }


So basically my question is does anyone know of a way for me to read a line of the playlist file (sort of like how Scanner works),which is stored online, and store that line as a String or URL object variable so I can play it?

Thanks
Reply With Quote Quick reply to this message  
Join Date: Nov 2004
Posts: 6,143
Reputation: jwenting is just really nice jwenting is just really nice jwenting is just really nice jwenting is just really nice 
Solved Threads: 213
Team Colleague
jwenting's Avatar
jwenting jwenting is offline Offline
duckman

Re: Audio: Reading Internet "Playlist" and outputting audio

 
0
  #2
Nov 26th, 2005
You'll have to read in the entire file (that's the way a URL works), parse it, and distribute the lines yourself.
As people are clearly allowed to attack me but I'm not allowed to defend myself, I no longer post to this site.
Reply With Quote Quick reply to this message  
Join Date: Jun 2004
Posts: 2,108
Reputation: server_crash is on a distinguished road 
Solved Threads: 18
server_crash server_crash is offline Offline
Postaholic

Re: Audio: Reading Internet "Playlist" and outputting audio

 
0
  #3
Nov 26th, 2005
Can you not just create an AudioClip object with the corresponding URL and then call the play() method on it?
Reply With Quote Quick reply to this message  
Join Date: Dec 2004
Posts: 27
Reputation: Frank0051 is an unknown quantity at this point 
Solved Threads: 0
Frank0051 Frank0051 is offline Offline
Light Poster

Re: Audio: Reading Internet "Playlist" and outputting audio

 
0
  #4
Nov 27th, 2005
Well see the problem with creating a clip is that I cannot because the first file I'm referencing is a playlist file that has the list of the files I want to retrieve. I also want to stream the file instead of a complete memory storage (like a clip) so the program uses little memory and can be streammed from even dail-up at reasonable speeds.

I have been looking at the XML parsing coding and it seems a little complex, so I hope the URL object parsing is a little earier. Could someone point me to a tutorial on parsing URL objects?

Thanks
Reply With Quote Quick reply to this message  
Join Date: Mar 2004
Posts: 763
Reputation: Phaelax is on a distinguished road 
Solved Threads: 38
Phaelax Phaelax is offline Offline
Master Poster

Re: Audio: Reading Internet "Playlist" and outputting audio

 
0
  #5
Nov 28th, 2005
what format is the playlist?

You might want to take a look at javazoom.com, his mp3 library supports shoutcast streams.
Reply With Quote Quick reply to this message  
Join Date: Dec 2004
Posts: 27
Reputation: Frank0051 is an unknown quantity at this point 
Solved Threads: 0
Frank0051 Frank0051 is offline Offline
Light Poster

Re: Audio: Reading Internet "Playlist" and outputting audio

 
0
  #6
Nov 28th, 2005
Thanks I will take a look at that.

My playlist is basically a text file that has the URL of the different files on seperate lines, no fancy coding or anything.

Originally Posted by Phaelax
what format is the playlist?

You might want to take a look at javazoom.com, his mp3 library supports shoutcast streams.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC