android MediaPlayer not playing mp3 file

I have written the most basic application I can think of to try to play an mp3 file, but it is not working. I don't get any errors, but when the application starts up, the sound is not played.

public class soundtest extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        MediaPlayer mp = new MediaPlayer();
        mp.create(getApplicationContext(), R.raw.norm_iphone_money);
        mp.start();
    }
}

What am I missing? I have "norm_iphone_money.mp3" inside the res/raw folder. The file plays fine in Windows Media Player and iTunes.

I'm using the latest versions of Java SDK and Eclipse for Java. The app is targeted for Android 2.2 and runs fine in the emulator despite no sound.

12
задан user613832 12 February 2011 в 01:11
поделиться