The mistake in your code is that you're passing a bare filedescriptor. For
an AssetFileDescriptor like you get for a resource, you should pass the
filedescriptor, the start offset and the length.
This is because you're not actually getting a filedescriptor for just the
resource (which would require storing the resource somewhere as a separate
file), but for your entire .apk file, along with the offset inside the apk
file and the length of the resource.


On Mon, May 25, 2009 at 3:49 PM, Moons <[email protected]> wrote:

>
> Hello everyone.
> I'm experiencing some sort of problem. Let's say I have a MediaPlayer
> object wich can play an audio sound and a Resources object:
>
> Code:
> resources = new Resources(this.getAssets(), new DisplayMetrics(), new
> Configuration());
> mp1 = MediaPlayer.create(this, R.raw.sound1);
>
> So when I invoke mp1.start() , sound1 plays, everything's normal.
>
> But when I try to change the sound that my MediaPlayer should play, it
> doesn't work, here is what I do:
>
>        mp1.reset(); //=>So mp1 is in the Idle state
>        mp1.setDataSource(resources.openRawResourceFd
> (R.raw.sound2).getFileDescriptor()); //State : Initialized
>        mp1.prepare(); //State : Prepared
>        mp1.start(); //Doesn't work here!!
>
> I'm pretty sure someone can see a mistake in my code.
> Tank you for your help.
>
> Moons
>
>
> >
>

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