I have a simple application that starts with a splash screen activity that plays mp4 video in VideoView. When the video is completed, I try to start a new action using the OnCompletionListener.
When I launch the application, the video works fine; playing both sound and sound as expected. As soon as the video ends, the application displays a dialog with the heading “Unable to play video” and continues normally as soon as the “OK” button is pressed. The problem only occurs when I added audio to mp4, which I created using Adobe After Effects. I used the same video minus the audio track, and it does not throw this error. I assume that the encoding of the file is fine, as it reproduces completely before showing the dialog.
Here is my code:
public class Splash extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.splash);
Uri video = Uri.parse("android.resource://" + getPackageName() + "/" + R.raw.audio_intro);
VideoView videoview = (VideoView) findViewById(R.id.splash_view);
videoview.setKeepScreenOn(true);
videoview.setVideoURI(video);
videoview.setOnCompletionListener(new OnCompletionListener() {
public void onCompletion(MediaPlayer mp) {
Intent intent = new Intent(Splash.this, Menu.class);
startActivity(intent);
finish();
}
});
videoview.requestFocus();
videoview.start();
}
}
Here, what LogCat shows:
06-30 14:49:33.095: V/MediaPlayer-JNI(21544): native_setup
06-30 14:49:33.095: V/MediaPlayer(21544): constructor
06-30 14:49:33.095: V/MediaPlayer(21544): setListener
06-30 14:49:33.095: I/MediaPlayer(21544): path is null
06-30 14:49:33.095: V/MediaPlayer-JNI(21544): setDataSourceFD: fd 54
06-30 14:49:33.095: V/MediaPlayer(21544): setDataSource(54, 2521, 173889)
06-30 14:49:33.110: V/MediaPlayer(21544): setVideoSurfaceTexture
06-30 14:49:33.110: V/MediaPlayer-JNI(21544): setAudioStreamType: 3
06-30 14:49:33.110: V/MediaPlayer(21544): MediaPlayer::setAudioStreamType
06-30 14:49:33.110: V/MediaPlayer(21544): setVideoSurfaceTexture
06-30 14:49:33.110: V/MediaPlayer(21544): prepareAsync
06-30 14:49:33.140: V/MediaPlayer(21544): message received msg=5, ext1=480, ext2=270
06-30 14:49:33.140: V/MediaPlayer(21544): New video size 480 x 270
06-30 14:49:33.140: V/MediaPlayer(21544): callback application
06-30 14:49:33.140: V/MediaPlayer(21544): back from callback
06-30 14:49:33.140: V/MediaPlayer(21544): message received msg=1, ext1=0, ext2=0
06-30 14:49:33.140: V/MediaPlayer(21544): prepared
06-30 14:49:33.140: V/MediaPlayer(21544): callback application
06-30 14:49:33.140: V/MediaPlayer(21544): back from callback
06-30 14:49:33.145: I/MediaPlayer(21544): mOnVideoSizeChangedListener. Send MEDIA_SET_VIDEO_SIZE message.
06-30 14:49:33.145: V/MediaPlayer(21544): getVideoWidth
06-30 14:49:33.145: V/MediaPlayer-JNI(21544): getVideoWidth: 480
06-30 14:49:33.145: V/MediaPlayer(21544): getVideoHeight
06-30 14:49:33.145: V/MediaPlayer-JNI(21544): getVideoHeight: 270
06-30 14:49:33.145: I/MediaPlayer(21544): mOnPreparedListener. Send MEDIA_PREPARED message.
06-30 14:49:33.145: D/MediaPlayer(21544): getMetadata
06-30 14:49:33.145: V/MediaPlayer(21544): getVideoWidth
06-30 14:49:33.145: V/MediaPlayer-JNI(21544): getVideoWidth: 480
06-30 14:49:33.145: V/MediaPlayer(21544): getVideoHeight
06-30 14:49:33.145: V/MediaPlayer-JNI(21544): getVideoHeight: 270
06-30 14:49:33.170: I/MediaPlayer(21544): sendBroadcast android.media.IMediaPlayer.videoexist
06-30 14:49:33.170: V/MediaPlayer-JNI(21544): start
06-30 14:49:33.170: V/MediaPlayer(21544): start
06-30 14:49:37.915: V/MediaPlayer(21544): message received msg=100, ext1=1, ext2=-1007
06-30 14:49:37.915: E/MediaPlayer(21544): error (1, -1007)
06-30 14:49:37.915: V/MediaPlayer(21544): callback application
06-30 14:49:37.915: V/MediaPlayer(21544): back from callback
06-30 14:49:37.915: E/MediaPlayer(21544): Error (1,-1007)
06-30 14:49:37.915: D/VideoView(21544): Error: 1,-1007
I hope someone can help me, as I have tried several things to solve this problem and it seems that I cannot find a similar problem that is mentioned / solved anywhere. Thank.