Here my code:
public class SplashActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Set portrait orientation
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
// Hide title bar
requestWindowFeature(Window.FEATURE_NO_TITLE);
try {
VideoView videoHolder = new VideoView(this);
setContentView(videoHolder);
Uri video = Uri.parse("android.resource://" + getPackageName() + "/" + R.raw.x);
videoHolder.setVideoURI(video);
videoHolder.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {
public void onCompletion(MediaPlayer mp) {
jump();
}
});
videoHolder.start();
} catch (Exception ex) {
jump();
}
}
@Override
public boolean onTouchEvent(MotionEvent event) {
jump();
return true;
}
private void jump() {
if (isFinishing())
return;
startActivity(new Intent(this, LoginActivity.class));
finish();
}
}
At the moment I run the application the screen throws me an error that says
"Unable to play the video"
However I upload my next activity with no problem after the error message, I did the SplashActivity
with a .Gif and it did without problem, the thing is that I want the animations to start have sound, so I try to implement a video with the same content as .Gif