I am trying to display a mp4 file that I added to my resources for android ressources in res/raw , for example:
public class Main extends RoboActivity
{
@InjectView (R.id.introVideo)
private VideoView introVideo;
private MediaPlayer player;
@Override
public void onCreate (Bundle savedInstanceState)
{
super.onCreate (savedInstanceState);
requestWindowFeature (Window.FEATURE_NO_TITLE);
getWindow (). setFlags (WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView (R.layout.main);
player = MediaPlayer.create (this, R.raw.intro_video2);
SurfaceHolder holder = introVideo.getHolder ();
player.setDisplay (holder);
player.start ();
player.setOnCompletionListener (new OnCompletionListener () {
public void onCompletion (MediaPlayer mp)
{
startActivity (new Intent (Main.this, Story.class));
releasePlayer ();
}
});
}
@Override
protected void onPause ()
{
super.onPause ();
releasePlayer ();
}
@Override
protected void onDestroy ()
{
super.onDestroy ();
releasePlayer ();
}
private void releasePlayer ()
{
if (player! = null)
{
player.release ();
}
}
}
but all i experience is the sound of the video, the screen remains blank on my Samsung GalaxyTab. The source file is an mp4 file (H.264 AVC, 960x640, 30 frames per second) and can play perfectly with Quicktime and VLC.
I tried to zoom out and resize the original video using Handbrake, up to 480x320 and 25 frames per second, I tried several settings in the handbrake, all without success.
Something is clearly wrong with my code, or is it a video format or something else - what am I doing wrong?
Thanks in advance, Thomas.
source share