Skip to content Skip to sidebar Skip to footer

Android Mediaplayer Not Playing Sound On Some Devices

I have made a simple alert beep for my application. But the problem is that the sound is played on some devices and in some others not. The sample code below: public void audioPlay

Solution 1:

Make sure the volume is up, otherwise you won't hear anything.

Generally it's not really advised to turn the volume up programmatically without any user input - if the volume is down it's usually through user action in the first place.

But here's how you can do it:

AudioManageram= (AudioManager) getSystemService(Context.AUDIO_SERVICE);
am.setStreamVolume(AudioManager.STREAM_MUSIC, am.getStreamMaxVolume(AudioManager.STREAM_MUSIC), 0);

This will max out STREAM_MUSIC. There are many other ways to control/change volume.

Have a read through this as well to familiarise yourself with controlling volumes: http://developer.android.com/training/managing-audio/volume-playback.html

Solution 2:

Your sound file shoudn't contain Special characters like _ (Underscore) and all. Try it by renaming into doubledeep. Also it should not starts with Capital Letter.

Post a Comment for "Android Mediaplayer Not Playing Sound On Some Devices"