Hi --

I sorted out my problem.  I found the answer in someone's blog.
it turns out that I have to pass the startOffset and the length to the
setDataSource(), and those are obtained via
the AssetFileDescriptor:

AssetFileDescriptor afd = getAssets().openFd(fileName);
mp.setDataSource(afd.getFileDescriptor(), afd.getStartOffset(),
afd.getLength());

That does the trick


On Jun 30, 11:15 pm, appsgrrl <bettyoch...@gmail.com> wrote:
> I've gotten the MediaPlayer to work with the create() on a resource.
> I'm trying to get it to work with a file in the assets folder.  I've
> tried all sorts of combinations with the setDataSource() method, but I
> keep getting errors.
>
> Here's one of my error traces:
>
> E/PlayerDriver(   31): Command PLAYER_SET_DATA_SOURCE completed with
> an error or info PVMFErrNotSupported
> E/MediaPlayer( 1550): error (1, -4)
> E/com.appsgrl.xxx.playerserv...@43d251f0( 1550): IOException on
> setDataSource:Prepare failed.: status=0x1
> W/PlayerDriver(   31): PVMFInfoErrorHandlingComplete
> E/MediaPlayer( 1550): start called in state 0
> E/MediaPlayer( 1550): error (-38, 0)
>
> I was trying to do the following:  (I did not show the try/catch
> stuff)
>
>          MediaPlayer mp = new MediaPlayer();
>          FileDescriptor sfd =
> getAssets().openFd("abc.wav").getFileDescriptor();
>
>          mp.setDataSource(sfd);
>          mp.prepare();
>          mp.start()
>
> Does anyone have a simple example of how to play something from the
> asses folder?
>
> Thanks

-- 
You received this message because you are subscribed to the Google
Groups "Android Beginners" group.

NEW! Try asking and tagging your question on Stack Overflow at
http://stackoverflow.com/questions/tagged/android

To unsubscribe from this group, send email to
android-beginners+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en

Reply via email to