Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Linux Archive
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 10-11-2008, 03:53 PM
Member
 
Join Date: Oct 2008
Posts: 27
arnab321 is on a distinguished road
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

}
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 10-11-2008, 05:08 PM
Norm's Avatar
Senior Member
 
Join Date: Jun 2008
Location: Heredia, Costa Rica
Posts: 2,225
Norm is on a distinguished road
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?
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Outputstream not streaming. dantestein Networking 0 10-11-2008 12:57 AM
PeerStream Audio Video Streaming Server 4.73 Java Tip Java Announcements 0 05-06-2008 08:46 PM
video streaming anniya0n Database 1 01-24-2008 07:35 PM
PeerStream Audio Video Streaming Server 4.55 JavaBean Java Announcements 0 10-27-2007 09:34 PM
PeerStream Audio Video Streaming Server 4.61 levent Java Announcements 0 07-31-2007 09:50 PM


All times are GMT +3. The time now is 03:39 PM.


VBulletin, Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org