I think you have to use the SurfaceHolder callbacks to find out when the surface has actually been created, and *then* call setDisplay/prepare/start
On Sat, Feb 14, 2009 at 4:28 PM, Brendan <[email protected]> wrote: > > Thanks for all your help! I've been trying out your original idea, but > I still seem to be having issues. > > I have moved the SurfaceView to main.xml, it looks like this: > > <?xml version="1.0" encoding="utf-8"?> > <LinearLayout xmlns:android="http://schemas.android.com/apk/res/ > android" > android:orientation="vertical" > android:layout_width="fill_parent" > android:layout_height="fill_parent" > > > <SurfaceView android:id="@+id/surface_view" > android:layout_height="fill_parent" > android:layout_width="fill_parent"></SurfaceView> > </LinearLayout> > > And now onCreate looks like this: > > setContentView(R.layout.main); > SurfaceView sv = (SurfaceView) findViewById > (R.id.surface_view); > > SurfaceHolder holder = sv.getHolder(); > holder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS); > > try { > MediaPlayer mp = new MediaPlayer(); > AssetFileDescriptor afd = getResources().openRawResourceFd > (R.raw.video); > mp.setDataSource(afd.getFileDescriptor(), afd.getStartOffset(), > afd.getLength()); > afd.close(); > mp.setDisplay(holder); > mp.prepare(); > mp.start(); > } catch {...} > > There are no errors ever thrown, but the process dies on mp.prepare() > without any warning or useful debug info. Is there potentially some > other way I should be setting the data source for a resource? Or > something else I'm forgetting to do that would make prepare > mysteriously kill the entire process? > > On Feb 14, 3:16 pm, Marco Nelissen <[email protected]> wrote: > > On Sat, Feb 14, 2009 at 3:01 PM, Brendan <[email protected]> wrote: > > > > > Wow that sounds really convenient. Since the signature of the > > > MediaPlayer.create() that takes a SurfaceHolder requires the second > > > argument to be a URI and not a resource id, I tried creating a URI for > > > the resource by doing this: > > > > Oh, right, of course. My original comment stands then :) > > You'll have to use "new MediaPlayer" instead of the MediaPlayer.create > > convenience method. > > > --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---

