android videoview error 1, -2147483648

匿名 (未验证) 提交于 2019-12-03 03:03:02

问题:

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.

回答1:

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.



回答2:

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



回答3:

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



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!