Problem with MediaPlayer

All your problems with Audio, Video and Images.

Problem with MediaPlayer

Postby Pzyber » Sun Feb 27, 2011 9:58 pm

I'm trying to play a soundfile using MediaPlayer but I'm getting this exception:

21:51:13.435 2514 ERROR AndroidRuntime Caused by: android.content.res.Resources$NotFoundException: File res/raw/test.mp3 from drawable resource ID #0x7f030000

MainActivity.java
Code: Select all
package org.me.testsound;

import android.app.Activity;
import android.media.MediaPlayer;
import android.os.Bundle;

public class MainActivity extends Activity {

    private MediaPlayer mp;

    @Override
    public void onCreate(Bundle icicle) {
        super.onCreate(icicle);

        mp = MediaPlayer.create(this, R.raw.test);
        mp.start();
    }
}


R.java
Code: Select all
/* AUTO-GENERATED FILE.  DO NOT MODIFY.
*
* This class was automatically generated by the
* aapt tool from the resource data it found.  It
* should not be modified by hand.
*/

package org.me.testsound;

public final class R {
    public static final class attr {
    }
    public static final class layout {
        public static final int main=0x7f020000;
    }
    public static final class raw {
        public static final int test=0x7f030000;
    }
    public static final class string {
        public static final int app_name=0x7f040000;
    }
}


The file is in /res/raw/ so that's not the problem.

I'm targetting Android 2.2 and I'm getting the exception in the emulator and on my phone.

Any suggestiongs what might be wrong?
Pzyber
Freshman
Freshman
 
Posts: 3
Joined: Sun Feb 27, 2011 9:19 pm

Top

Re: Problem with MediaPlayer

Postby Pzyber » Sun Feb 27, 2011 10:34 pm

Something must be wrong with the combination netbeans + android sdk. eclipse users can build it without getting the error.
Pzyber
Freshman
Freshman
 
Posts: 3
Joined: Sun Feb 27, 2011 9:19 pm

Re: Problem with MediaPlayer

Postby Pzyber » Mon Feb 28, 2011 12:23 am

I solved it.

- Uninstalled netbeans 6.9.1
- Uninstalled java se jdk 6u23
- Deleted all netbeans settings including the nbandroid 0.11 plugin

- Updated Android SDK from 8 till 10
- Installed java se jdk 6u24
- Installed netbeans 6.9.1 again
- installed nbandroid 1.0beta

Then it worked!
Pzyber
Freshman
Freshman
 
Posts: 3
Joined: Sun Feb 27, 2011 9:19 pm

Top

Return to Multimedia Problems

Who is online

Users browsing this forum: Google [Bot] and 16 guests