Try putting the start() call in onResume().

On Feb 21, 4:58 am, Alex Coventry <[email protected]> wrote:
> The following code crashes when I try to play it on my droid. The
> error message given in the log is "Command PLAYER_INIT completed with
> an error or info PVMFErrNoResources."  Then an IOExecption is raised.
> There is a file "res/raw/bell.mp3" in my project directory, which I
> assume corresponds to R.raw.bell in the code below. I am building with
> "ant debug". In case it's relevant, when I created the project
> directory with "android create", I set the target number to 4,
> corresponding in my system to "android 2.0."
>
> What am I doing wrong, here?
>
> import java.io.IOException;
> import android.app.Activity;
> import android.os.Bundle;
> import android.media.MediaPlayer;
> import android.util.Log;
>
> public class testapp extends Activity
> {
>     /** Called when the activity is first created. */
>     @Override
>     public void onCreate(Bundle savedInstanceState)
>     {
>         super.onCreate(savedInstanceState);
>  try {
>      MediaPlayer mp = MediaPlayer.create(this, R.raw.bell);
>      mp.prepare();
>      mp.start();
>  } catch (IOException e) {
>      Log.v(getString(R.string.app_name), e.getMessage());
>  }
>     }
>
> }
>
>

-- 
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