When I am starting the app, the Video should be played. But I can only hear the Sound.
I know that the solution for this Problem is to use the SurfaceHolder. But I am already using it.
I don't know if there is missing something in my Code or if the problem is somewhere else.
I already searched for solutions in this forum and with google, but i did not found any differences in the code structure.
This is my LayoutFile:
Using xml Syntax Highlighting
- <?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="250px"
- android:layout_height="250px"
- android:layout_gravity="center">
- </SurfaceView>
- </LinearLayout>
Parsed in 0.002 seconds, using GeSHi 1.0.8.4
and this my ActivityClass:
Using java Syntax Highlighting
- public class Mainmenu extends Activity{
- private static final String TAG = "MediaPlayerDemo";
- private MediaPlayer mMediaPlayer;
- private SurfaceView mPreview;
- private SurfaceHolder holder;
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.main);
- mPreview = (SurfaceView) findViewById(R.id.surface);
- holder = mPreview.getHolder();
- holder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
- try
- {
- mMediaPlayer = MediaPlayer.create(this, R.raw.test);
- mMediaPlayer.setDisplay(holder);
- mMediaPlayer.start();
- }
- catch(Exception e){Log.e(TAG, "error: " + e.getMessage(), e);}
- }
- }
Parsed in 0.033 seconds, using GeSHi 1.0.8.4
I only want to know how to start a Video.
There is no error an no exception. The file is in the raw Folder and i can hear the sound without Problems.
I tried it with an mp4 and an 3gp videofile. The 3gp was captured with an G1.
And it makes no difference if i start the app with an emulator or with my G1.
So there must be something wrong with my code... but i dont know what.


