android - FileNotFoundException with MediaPlayer.create() reading from /res/raw -


i have tiny uncompress .wav file in /res/raw directory called keyclick.wav (/res/raw/keyclick.wav).

however, i'm seeing exception thrown causes activity crash:

java.io.filenotfoundexception: file can not opened file descriptor; compressed @ ... android.content.res.assetmanager.opennonassetfdnative(native method) android.content.res.assetmanager.opennonassetfd(assetmanager.java:427) android.content.res.resources.openrawresourcefd(resources.java:857) android.media.mediaplayer.create(mediaplayer.java:662) 

it says "it compressed" i've double checked, not compressed.

this how instantiate mediaplayer:

this.clickplayer = mediaplayer.create(this.getactivity(), r.raw.keyclick); 

i uploaded file can see directly:

http://inadaydevelopment.com/stackoverflow/keyclick.wav

the file 664 bytes , it's not compressed. why system failing file descriptor?

kenny, have tried playing file using approach:

mediaplayer mp = new mediaplayer(); assetfiledescriptor afd = getresources().openrawresourcefd(r.raw.keyclick); mp.setdatasource(afd.getfiledescriptor(), afd.getstartoffset(), afd.getlength()); mp.prepare(); mp.start(); 

Comments

Popular posts from this blog

ios - iPhone/iPad different view orientations in different views , and apple approval process -

java Extracting Zip file -

C# WinForm - loading screen -