On Sun, Mar 1, 2009 at 4:55 PM, Paper Coder <[email protected]> wrote: > I didn't realize it wouldn't return the media player until it was ready to > play. > > Now the methods in media player make much more sense. I was wondering why > there wasn't a way to create a new media player object with the new keyword, > then set the resource id.
You can't set the resource id directly, but you can get a filedescriptor for the resource. Something like: MediaPlayer mp = new MediaPlayer(); AssetFileDescriptor afd = getContext().getResources().openRawResource(R.raw.yourmp3resource); mp.setDataSource(afd.getFileDescriptor(), afd.getStartOffset(), afd.getLength()); mp.prepare(); mp.start(); --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---

