我使用videoview从本地媒体服务器打开视频。效果很好,但是logcat显示每次打开视频时,都会产生FileNotFoundException:
2019-01-08 13:42:47.434 27583-27583/com.myapp.contentplayer W/MediaPlayer: Couldn't open http://10.0.0.10:3303/videos/55.mp4: java.io.FileNotFoundException: No content provider: http://10.0.0.10:3303/videos/55.mp4
2019-01-08 13:42:47.436 27583-27583/com.myapp.contentplayer D/MediaPlayer: setDataSource IOException | SecurityException happend :
java.io.FileNotFoundException: No content provider: http://10.0.0.10:3303/videos/55.mp4
at android.content.ContentResolver.openTypedAssetFileDescriptor(ContentResolver.java:1402)
at android.content.ContentResolver.openAssetFileDescriptor(ContentResolver.java:1253)
at android.content.ContentResolver.openAssetFileDescriptor(ContentResolver.java:1176)
at android.media.MediaPlayer.attemptDataSource(MediaPlayer.java:1182)
at android.media.MediaPlayer.setDataSource(MediaPlayer.java:1154)
at android.media.MediaPlayer.setDataSource(MediaPlayer.java:1178)
at android.widget.VideoView.openVideo(VideoView.java:399)
at android.widget.VideoView.-wrap0(Unknown Source:0)
at android.widget.VideoView$7.surfaceCreated(VideoView.java:678)
at android.view.SurfaceView.updateSurface(SurfaceView.java:773)
at android.view.SurfaceView$2.onPreDraw(SurfaceView.java:153)
at android.view.ViewTreeObserver.dispatchOnPreDraw(ViewTreeObserver.java:1045)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2944)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1863)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:8072)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:911)
at android.view.Choreographer.doCallbacks(Choreographer.java:723)
at android.view.Choreographer.doFrame(Choreographer.java:658)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:897)
at android.os.Handler.handleCallback(Handler.java:790)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:7000)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:441)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1408)
视频可以播放,我可以暂停,继续播放,一切正常,但是异常让我担心。
这是创建视图的代码。播放和暂停是在其他地方完成的,但是即使能够很好地播放视频,删除控件甚至不播放视频也足以导致错误。
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(LayoutParams.FLAG_FULLSCREEN, LayoutParams.FLAG_FULLSCREEN);
setContentView(layout.activity_video_fullscreen);
mWV = (VideoView) findViewById(R.id.video_full);
mWV.setVideoURI(Uri.parse(getIntent().getStringExtra("video_url")));
有人知道这回可以咬我吗?或即使不能解决问题,也可以解决(表观)问题(尝试捕获并忽略它)?