I'm an Android novice, but what do you think about this solution?

MediaPlayer mNotify;
mNotify = MediaPlayer.create(this, R.raw.beep);
mNotify.start();

It should play your audio file without problems

On 23 Set, 04:13, CG <[EMAIL PROTECTED]> wrote:
> Hey,
>
> I try to play a local sound in a notification. The issue I meet is the
> folowing : I am unable to load the file.
>
> My code is :
>
> Uri uri = Uri.parse("android.resource://com.xirgonium.android/raw/
> beep");
> mNotify.sound = uri;
>
> The package name is the one described in my manifest.
>
> I get the error :
>
> 09-23 01:55:12.692: WARN/NotificationService(47): error loading sound
> for android.resource://com.xirgonium.android/raw/beep
> 09-23 01:55:12.692: WARN/NotificationService(47): java.io.IOException:
> Prepare failed.: status=0xFFFFFFFC
> 09-23 01:55:12.692: WARN/NotificationService(47):     at
> android.media.MediaPlayer.prepare(Native Method)
> 09-23 01:55:12.692: WARN/NotificationService(47):     at
> android.media.AsyncPlayer$Thread.run(AsyncPlayer.java:76)
>
> Now if I try (as defined here 
> :http://code.google.com/android/reference/android/content/ContentResol...
> Uri uri = Uri.parse("android.resource://" + PACKAGE_NAME + "/" +
> R.raw.beep);
> I get the error :
> 09-23 02:05:05.690: WARN/NotificationService(47): error loading sound
> for android.resource://com.xirgonium.android/2131034112
> 09-23 02:05:05.690: WARN/NotificationService(47): java.io.IOException:
> Prepare failed.: status=0xFFFFFFFC
> 09-23 02:05:05.690: WARN/NotificationService(47):     at
> android.media.MediaPlayer.prepare(Native Method)
> 09-23 02:05:05.690: WARN/NotificationService(47):     at
> android.media.AsyncPlayer$Thread.run(AsyncPlayer.java:76)
>
> I am pretty sure the package name is correct because I have the
> folowing apk in my emulator :
> -rw-r--r-- system   system     263463 2008-09-23 02:04
> com.xirgonium.android.apk
>
> I just try to load a .wav file.
>
> Can anyone help me on this point (code snippet is sufficient :-)) Or
> how can I be sure the file is in my apk ?
>
> Thanks for your help !
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
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