small medium large xlarge

02 Nov 2009, 14:06
Kevin Graham (5 posts)

I’m having trouble with the Audio project. Of the up, down, left, right, enter, a, s, d, and f audio files, the last two MediaPlayers created throw errors. The LogCat says the following:

PlayerDriver - Command PLAYER PREPARE completed with an error or info PVMFErrResource MediaPlayer - error(1, -17) MediaPlayer - create failed: MediaPlayer - Prepare failed.: status=0x1 MediaPlayer - at Method)

Can someone point me to a resource for the error codes? It’s behaving like there is a resource problem. Anyone else have problems like this one?

Thanks, Kevin

03 Nov 2009, 16:21
Ed Burnette (1342 posts)

I got that once but couldn’t reproduce it. I’ll try to track it down but I doubt you’ll encounter this in your own programs, especially if you take my advice to use .ogg files instead of .mp3 for short sound effects. .ogg files go through a completely different path in the audio decoder.

06 Nov 2009, 08:00
Bill Anderson (4 posts)

I’m seeing the exact same thing. I am running it on an Android 2.0-based Emulator. Perhaps I should target 1.5 and see what happens. I’ll try converting the files to .ogg as well.


06 Nov 2009, 08:08
Bill Anderson (4 posts)

Converted everything to .ogg and it works fine…


18 Nov 2009, 00:00
Ed Burnette (1342 posts)

I tracked this problem down and it’s caused by having too many MediaPlayer objects active at once. You wouldn’t think that 8 or 9 would be too many, but apparently it is in Android 2.0 and maybe in 1.6. The maximum number is not documented.

To fix the example, I could do one of the following:

  1. I could use fewer sounds, e.g., just up, down, left, and right, which hopefully wouldn’t run into the limit.
  2. I could put in error checking to test for a null MediaPlayer before playing it. That would get rid of the Force Close but not produce sound for some keys.
  3. I could use .ogg instead of .mp3, because .ogg seems to have a higher limit on the number of players and .ogg files start playing quicker than .mp3 files (good for sound effects).
  4. I could create a new MediaPlayer when the button was pressed and try to make sure it’s cleaned up correctly and that no more than a low number are created if you press several keys.
  5. I could create one MediaPlayer and stop and reuse it when a button is pressed. Anything playing would be truncated so that only one sound would be heard at a time.
  6. I could use SoundPool instead of MediaPlayer.

I don’t want to make the example complicated because that would get in the way of teaching the reader a simple concept that will then be plugged into the Sudoku game. So I’m leaning towards #1 or #5. Opinions are welcome.

01 Dec 2009, 16:16
Felix Bearden (1 post)

I like #5. It also may be useful to mention that limit in further versions of the book (referencing the version of Android) so people that like to optimize don’t run into the same problem.

22 Feb 2010, 22:35
Erik Anderson (2 posts)

I would vote for #3 as it doesn’t involve anything other than switching out files. However, who’s to say some limit won’t be encountered with that option? With that in mind, and other possible limitations to be encountered, I vote for #5.

23 Feb 2010, 01:38
Ed Burnette (1342 posts)

I decided to go with #5. The latest version of the examples can be found in the 3rd edition samples at .

26 Nov 2016, 17:17
mazar ali (2 posts)

In addition to MDA Day, Dutch Bros. Coffee reinvests 1 percent of its annual gross sales back into its local communities, and in 2010, the company donated more than $1 million to nonprofit organizations including local food banks, American Cancer Society and Boys & Girls Clubs of America and many other organizations. jogos de carros

26 Nov 2016, 17:19
mazar ali (2 posts)

the Wiley Publishing logo, For Dummies, the Dummies Man logo, A Reference for the Rest of Us!, The Dummies Way, Dummies Daily, The Fun and Easy Way, and related trade dress are trademarks or registered trademarks of John Wiley & Sons, Inc. and/or its affiliates in the United States and other countries, and may not be used without written permission. All other trademarks are the property of their respective owners. Wiley Publishing, Inc., is not associated with any product or vendor jogos de moto

car games

hd wallpapers

You must be logged in to comment