| | |
Audio: Reading Internet "Playlist" and outputting audio
![]() |
•
•
Join Date: Dec 2004
Posts: 27
Reputation:
Solved Threads: 0
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:
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:
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
Java Syntax (Toggle Plain Text)
http://www.whatever.com/a.wav http://www.whatever.com/b.wav 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:
Java Syntax (Toggle Plain Text)
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) audioFormat = audioInputStream.getFormat(); DataLine.Info dataLineInfo = //Output line to hardware new DataLine.Info(SourceDataLine.class,audioFormat); if(debug==1) System.out.println("Loading to Mixer DataLine"); sourceDataLine = (SourceDataLine)AudioSystem.getLine(dataLineInfo); sourceDataLine.open(audioFormat); sourceDataLine.start(); int cnt; while((cnt = audioInputStream.read(tempBuffer,0,tempBuffer.length)) != -1){ if(cnt > 0){ if(debug==1) System.out.println("Writing Stream to Internal Buffer"); sourceDataLine.write(tempBuffer, 0, cnt); } }
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
•
•
Join Date: Dec 2004
Posts: 27
Reputation:
Solved Threads: 0
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
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
•
•
Join Date: Dec 2004
Posts: 27
Reputation:
Solved Threads: 0
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.
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.
![]() |
Similar Threads
- Internet "freezing" when playing audio or video files on certain sites. (Windows NT / 2000 / XP)
- "System Idle Process" (Windows NT / 2000 / XP)
Other Threads in the Java Forum
- Previous Thread: Printing JPanel containing JLable, JTable, JButton, JTextPane, JTextArea
- Next Thread: Any Java Multimedia Programs?
| Thread Tools | Search this Thread |
-xlint actionlistener android api applet application array arrays automation bi binary blackberry block bluetooth character class client code compile compiler component consumer database desktop developmenthelp eclipse error fractal freeze ftp game gameprogramming givemetehcodez graphics gui health html ide image integer j2me j2seprojects java javac javaee javaprojects jetbrains jni jpanel jtable julia learningresources lego linked linux list login loops mac main map method methods mobile netbeans notdisplaying number online printf problem program project properties qt recursion researchinmotion rotatetext rsa scanner screen server set singleton sms sort sql string swing system textfields threads time title tree tutorial-sample update variablebinding windows working xor






