• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps Android Emulator - No sound

Hey guys,

I'm brand new to Android and this forum and was hoping someone could please help :)

I've been trying out some of the basic tutorials and taking snippets of code from here and there until I tried using audio, in particular

Audio and Video | Android Developers

Using the Local file method, the code compiles fine however there is no sound, at first I thought it was a problem solely with my application but it was apparent that even the emulator volume controls should be making a sound.

I tried opening the Emulator through the command prompt and noticed the 3 lines:

emulator: using winaudio audio input backend
emulator: using winaudio audio output backend
emulator: Trace file name is not set

I understand that winaudio relates to Windows Wave but is there a problem with the Trace line?

I'm running Windows 7 32-bit, if that's any use.

Any help would be massively appreciated,

Quinton
 
The issue was not with the emulator not making sound ( as verified by
the fact it would not work on my device either ), but a unaccounted
problem with the SoundPool class.

I looked in the logcat and found references like "sample 1 not ready". Researching this I finally found a obscure thread in which it was mentioned that it takes some time before sound pool is ready to be used ( and therefore all sounds should be loaded well before they are used ).


I modified my playSound method to monitor the return value of the
soundPool.play(...) method call. It returns the id of the running
sound stream, or 0 if it failed ( i.e. "sample 1 not ready" ).
What I did was to put it into a loop, and when the return value of the
soundPool.play(...) method call was 0, I had the thread sleep for 1
millisecond, then try again. With this method in place, I now always
get a sound.
 
Upvote 0
I have also been having this problem. The funny thing is, it USED to work.

But a few weeks ago, it stopped working.

I am just using the simplified

mMediaPlayer = MediaPlayer.Create(context, resource) followed
by the mMediaPlayer.start().

I also tried using the code for the SoundPool which was mentioned in a
previous reply. Even though I don't get any errors, and the logic works
fine, I still do not get any sound.
 
Upvote 0

BEST TECH IN 2023

We've been tracking upcoming products and ranking the best tech since 2007. Thanks for trusting our opinion: we get rewarded through affiliate links that earn us a commission and we invite you to learn more about us.

Smartphones