I am trying to play a video through my application.
public class VideoScreen extends Activity {
public MediaPlayer videoMediaPlayer = new MediaPlayer();
public void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.videoscreen);
SurfaceView demoVideo = (SurfaceView) findViewById(R.id.demoVideo);
SurfaceHolder videoHolder = demoVideo.getHolder();
videoMediaPlayer = MediaPlayer.create(this, R.raw.help);
videoMediaPlayer.setDisplay(videoHolder);
videoMediaPlayer.setLooping(false);
videoMediaPlayer.setScreenOnWhilePlaying(true);
videoMediaPlayer.start();
}
}
XML File:
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_height="fill_parent">
<SurfaceView android:id="@+id/demoVideo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"></SurfaceView>
</FrameLayout>
I can hear only sound, but no video.
But, when I try to play this video separately through file manager. It is playing perfectly. Where I am wrong?
Please help.