I'd temporarily comment out your setVolume() until you get the rest working.

Make sure the emulator or device volume is set via the Settings app to
an appropriate level. Ideally, then test your emulator or device with
some other app, as I've had occasional problems getting the emulator
output to work with my development machine. Also, testing with the MP3
file would indicate if there is something goofy with the file itself.

Note that MediaPlayer tends not to raise exceptions but to log things
at *warning* level in LogCat.

FWIW, here is a sample app that also uses a raw resource for media playback:

https://github.com/commonsguy/cw-advandroid/tree/master/Media/Audio

In there, I use OGG. IIRC, OGG files worked better with looping way
back when, though I don't know if that is now better with Stagefright
than with the original OpenCORE media engine.

On Sat, Jan 7, 2012 at 9:41 AM, Raghav Sood
<[email protected]> wrote:
> Hi all,
>
> I am working on a new game and am trying to add some background music. I
> want this music to play across several activities, so I created a separate
> class to handle it. The music is a single 32 second mp3 file.
>
> In my class, I get the music ready in the onCreate() like this:
>
> mPlayer = MediaPlayer.create(this, R.raw.gametheme);
>
>
>  I then have two methods to start and stop the music:
>
>
> public static void play() {
>
> if(mSound == true)
>
> {
>
> soundPlaying = true;
>
> mPlayer.setLooping(true);
>
> mPlayer.setVolume(1.0f, 1.0f);
>
> mPlayer.start();
>
> }
>
> }
>
> public static void stop() {
>
> if (soundPlaying == true)
>
> {
>
> mPlayer.stop();
>
> }
>
> }
>
>
> However, when I call BackSound.play() the music doesn't play. (BackSound is
> the name of the class).  There is no exception or error. It just doesn't
> play.
>
> Any idea on how to do this?
>
> Thanks
> --
> Raghav Sood
> http://www.androidactivist.org/ - Author
> http://www.appaholics.in/ - Founder
>
> --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To post to this group, send email to [email protected]
> To unsubscribe from this group, send email to
> [email protected]
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en



-- 
Mark Murphy (a Commons Guy)
http://commonsware.com | http://github.com/commonsguy
http://commonsware.com/blog | http://twitter.com/commonsguy

Android Training in NYC: http://marakana.com/training/android/

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to