Which "Audio and Video dev guide" are you referring to? If that guide tells
you that the code you posted should work, it needs to be fixed :)
There are several problems in your code, but the main one is that you can't
use any of the MediaPlayer.create() convenience methods to play video from a
resource. This is because create() calls prepare() internally, but you need
to call setDisplay() before calling prepare().
You'll need to use "new MediaPlayer" and setDataSource and setDisplay
instead. Also be sure to wait for the surfaceCreated callback on the
SurfaceHolder before calling start().




On Wed, May 27, 2009 at 8:42 AM, Hamy <[email protected]> wrote:

>
> Hey all,
>
> I can only hear sound when trying to play a video in a surfaceView.
> The video codecs are very likely supported - I was reading this
> thread:
> http://groups.google.com/group/android-developers/browse_thread/thread/aeefa6c282c6dfcf
> where Mark Murphy mentions that the video is known to work.
>
> This is very straightforward code, right off the Audio and Video dev
> guide, so I am surprised I am having so much trouble with it.
>
> Thanks,
> Hamilton
>
> Here is all the code in my onCreate method
>        public void onCreate(Bundle savedInstanceState) {
>                super.onCreate(savedInstanceState);
>                setContentView(R.layout.main);
>
>                MediaPlayer mp = MediaPlayer.create(this,
> R.raw.documentariesandyou);
>                SurfaceView sv = (SurfaceView)findViewById(R.id.surface);
>                mp.setDisplay(sv.getHolder());
>                mp.start();
>        }
>
> and here is my XML
> <?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"
>                android:layout_width="fill_parent"
> android:layout_height="fill_parent" />
> </LinearLayout>
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to