It's good to know this, especially if I encounter other classes that seem to not be able to access resources easily. Although, if I encounter that situation again, it will set off a warning signal that there is probably an easier way to do it (as in checking for a null reference in media player to see if it's ready).
Thank again. On Mon, Mar 2, 2009 at 9:44 AM, Marco Nelissen <marc...@android.com> wrote: > > On Sun, Mar 1, 2009 at 4:55 PM, Paper Coder <paperga...@gmail.com> 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 android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~----------~----~----~----~------~----~------~--~---