Results 1 to 2 of 2
Thread: streaming mp3
- 10-11-2008, 01:53 PM #1
Member
- Join Date
- Oct 2008
- Posts
- 40
- Rep Power
- 0
streaming mp3
how do i stream an mp3 (downloading in chunks and playing)? i first downloaded a part of the file as bytearray, then converted it into inputStream using bytearrayinputstream. and then played it. but the player gives a start exception(it sucessfully realizes and prefetches). im testing my app in sony ericssion emulator, that suports mp3.
plz help me. point out whats wrong here:
the download function:
hcon = ( HttpConnection )Connector.open("any mp3 file url here");//<---
hcon.setRequestMethod(HttpConnection.GET);
stin=hcon.openInputStream();
InputStreamReader(hcon.openInputStream());
if (hcon.getResponseCode( ) == HttpConnection.HTTP_OK) {
ByteArrayOutputStream star = null;
byte stdata[]=new byte[500];
System.out.println("stream "+hcon.getHeaderField("content-type"));
//the content-type returned is "audio/mpeg"
int total = 0;
star = new ByteArrayOutputStream();
int ch;
System.out.println("length no");
while ((ch = stin.read()) != -1){System.out.println(ch);
System.out.println(stin.available());total++; System.out.println(total+" "+count);
star.write(ch);
if(total==500)break;//breaks if the bytearray has 500 entries
}
System.out.println("finished");
InputStream aa=new ByteArrayInputStream(star.toByteArray());//converting bytearray to inputstream
craze.PLY(aa);//the player class to plaay the inputstream
}
- 10-11-2008, 03:08 PM #2
Without all the code and the hardware, its very hard to help.
Are you sure that the data is being sent correctly?
Can you send a small file, read it and compare it against what was sent to see if the communications is working correctly?
What is a "start exception"? Can you copy and post the full text of the error message here?
Similar Threads
-
video streaming
By anniya0n in forum JDBCReplies: 3Last Post: 05-08-2013, 03:21 PM -
Outputstream not streaming.
By dantestein in forum NetworkingReplies: 2Last Post: 03-14-2009, 07:36 AM -
PeerStream Audio Video Streaming Server 4.73
By Java Tip in forum Java SoftwareReplies: 0Last Post: 05-06-2008, 06:46 PM -
PeerStream Audio Video Streaming Server 4.55
By JavaBean in forum Java SoftwareReplies: 0Last Post: 10-27-2007, 07:34 PM -
PeerStream Audio Video Streaming Server 4.61
By levent in forum Java SoftwareReplies: 0Last Post: 07-31-2007, 07:50 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks