I am getting error while playing video from asset folder and raw folder.
MediaPlayer error (1, -2147483648) VideoView error 1, -2147483648.
I tried from asset folder as.
private String SrcPath = "file:///android_asset/aaa.mp4"; //also tried aaaa.mp3 VideoView vv = (VideoView)findViewById(R.id.videoView1); vv.setVideoPath(SrcPath); MediaController controller = new MediaController(this); controller.setAnchorView(vv); vv.setMediaController(controller); vv.requestFocus(); vv.start();
and for raw folder i used URI as :
Uri video = Uri.parse("android.resource://com.usecontentprovider/raw/aaa.mp4"); vv.setVideoURI(video);
I got the same error message in both cases.
You can use software like avinaptic2 to get the video encoding information and make sure it matches the supported media formats in android.
A common problem I find is that videos are encoded with the wrong profiling. H.264 videos need to be encoded with Baseline level 3 or under to be played without errors or artifacts in Android.
I found the solution as I am able to play video on virtual device.
I replaced the line
Uri video = Uri.parse("android.resource://com.usecontentprovider/raw/aaa.mp4");
with
Uri video = Uri.parse("android.resource://com.usecontentprovider/raw/"+R.raw.aaa);
And its working
Using R.raw
works fine but in some cases I still get the same error. Fortunately I found the solution to my problem: I had to call videoView.start()
inside onPrepare()
.
You can check the correct answer here: Android: 'Can't play this video'; MediaPlayer & VideoView Error 1 -38