You Are Here:

Community: Developer Discussion Boards

#1 Old can't play wav from inputstream (no ending) - 2004-12-03, 17:47

Join Date: Nov 2004
Posts: 79
aluckybird
Offline
Regular Contributor
Hi

I am using MMAPI to create player to play a wav file from a bluetooth inputstream- which is always open, even after I finish playing.

When I use player.start(), I can only hear a sudden of noise then get exception: java.lan.negtiveArraySizeException. With the same code, I can play sound well from a http link, or a fileStream (getClass().getResourceAsStream()).
I tried to read from the bluetooth inputstream, InputStream.read(byteBuffer) blocks and never return after the whole file finished. I guess because I didn't get EOF in the stream. This I solved with inputStream.available() >0 as condition, then I got the right file.

Here is part of my code:
Code:
//connection is bluetooth StreamConnection
InputStream inputStream = connection.getInputStream();
public void run() {
       try {
	p = Manager.createPlayer(inputStream, "audio/X-wav");
	    p.addPlayerListener(this);
	    p.realize();
	    debugInfo("Realized");
	    p.prefetch();
                    debugInfo("Prefetched");
	    p.start();
                    debugInfo("started");

       } catch (IOException ioe) {
		ioe.printStackTrace();
      } catch (MediaException me) {
		me.printStackTrace();
      }
}
//Stop player on END_OF_MEDIA event.
My debug infomation shows the player is realized, prefefetched and started successfully, but can't play correctly, and give exceptions. My PlayerListener never get the END_OF_MEDIA event.
Well, I am not sure I explained my problem clear. can anybody help me?
Thanks in advance.
Last edited by aluckybird : 2004-12-03 at 17:59.
Reply With Quote

#2 Old Re: can't play file from inputstream (no ending) - 2005-12-01, 10:31

Join Date: Nov 2005
Posts: 9
gamermic
Offline
Registered User
is it because of the bandwidth or packet issue?
Reply With Quote

#3 Old Re: can't play file from inputstream (no ending) - 2005-12-01, 18:29

Join Date: Aug 2005
Posts: 29
simonhayles
Offline
Registered User
Different phones handle sound in different ways. Try not prefetching or realizing, or just prefetch or just realize &c.
Reply With Quote

#4 Old Re: can't play file from inputstream (no ending) - 2005-12-02, 08:49

Join Date: Jul 2003
Posts: 46
rantalah
Offline
Registered User
There's nothing wrong with the file itself. The implementation probably reads the whole content during realize or prefetch. If if can't get the EOF properly then that might be the reason for the failure.

You can try to wrap the InputStream of BT under your own InputStream implementation and your code could then provide the proper EOF when the file has been completely read.
Reply With Quote
Reply « Previous Thread | Next Thread »
Display Modes
Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
[IMG] code is Off
HTML code is Off
Forum Jump

Rate This

 
Bookmark this page: DeliciousDiggFacebookGoogleYahooStumbleUponRedditDiigoTechnocratiTwitter  Share this page Share this page Print this Page Print this page Invite a friend Invite a friend
京ICP备05048969号    Email Newsletters Press Terms & Conditions Privacy Policy Sitemap Contact Us © 2009 Nokia 
RDF Facets: qdcZidentifierQSxhttpE3aE2fE2fdiscussionE2eforumE2enokiaE2ecomE2fforumE2fshowthreadE2ephpE3ftE3d134434X qdcZtypeQUqfnZE45E78cludedFromGeneralE4cistingsQ qdcZtypeQUqfntypeZCommunityContentQ qdcZtypeQUqfntypeZE44iscussionQ qdcZtypeQUqfntypeZE44iscussionContentQ qdcZtypeQUqfntypeZE52esourceQ qdcZtypeQUqfntypeZWebpageQ qdcZtypeQUqmarsZManagedE52esourceQ qdcZtypeQUqwebZInformationE52esourceQ qdcZtypeQUqwebZPageQ qdcZtypeQUqwebZE52esourceQ qdcZtypeQUqrdfsZE52esourceQ qfnZtopicQUqfnTopicZentertainmentQ qfnZtopicQUqfnTopicZj2meQ qfnZtopicQUqfnTopicZjavaQ qfnZtopicQUqfnTopicZmediaQ qfnZtypeQUqfntypeZCommunityContentQ qfnZtypeQUqfntypeZE44iscussionQ qfnZtypeQUqfntypeZE44iscussionContentQ qfnZtypeQUqfntypeZE52esourceQ qfnZtypeQUqfntypeZWebpageQ qmarsZlanguageQUxhttpE3aE2fE2fswE2enokiaE2ecomE2flanguageE2d1E2fenX qrdfZtypeQUqfnZE45E78cludedFromGeneralE4cistingsQ qrdfZtypeQUqfntypeZCommunityContentQ qrdfZtypeQUqfntypeZE44iscussionQ qrdfZtypeQUqfntypeZE44iscussionContentQ qrdfZtypeQUqfntypeZE52esourceQ qrdfZtypeQUqfntypeZWebpageQ qrdfZtypeQUqmarsZManagedE52esourceQ qrdfZtypeQUqwebZInformationE52esourceQ qrdfZtypeQUqwebZPageQ qrdfZtypeQUqwebZE52esourceQ qrdfZtypeQUqrdfsZE52esourceQ