[英]Android VideoView I get randomly a "Can't play this video" error
我想使用VideoView
播放视频:
videoView.setVideoURI(Uri.parse("http://192.168.1.10:7777/mov_bbb.mp4"));
videoView.start();
它随机工作。 视频加载时间的 20%,然后开始。 但 80% 的时间,我都会收到此错误:
Can't play this video
这是输出到控制台:
W/MediaPlayer: Couldn't open http://192.168.1.10:7777/...
java.io.FileNotFoundException: No content provider: http://192.168.1.10:7777/mov_bbb.mp4
at android.content.ContentResolver.openTypedAssetFileDescriptor(ContentResolver.java:1673)
at android.content.ContentResolver.openAssetFileDescriptor(ContentResolver.java:1503)
at android.content.ContentResolver.openAssetFileDescriptor(ContentResolver.java:1420)
at android.media.MediaPlayer.attemptDataSource(MediaPlayer.java:1101)
at android.media.MediaPlayer.setDataSource(MediaPlayer.java:1073)
at android.media.MediaPlayer.setDataSource(MediaPlayer.java:1097)
at android.widget.VideoView.openVideo(VideoView.java:412)
at android.widget.VideoView.access$2200(VideoView.java:83)
at android.widget.VideoView$7.surfaceCreated(VideoView.java:694)
at android.view.SurfaceView.updateSurface(SurfaceView.java:758)
at android.view.SurfaceView$2.onPreDraw(SurfaceView.java:155)
at android.view.ViewTreeObserver.dispatchOnPreDraw(ViewTreeObserver.java:1088)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2745)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1721)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:7598)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:966)
at android.view.Choreographer.doCallbacks(Choreographer.java:790)
at android.view.Choreographer.doFrame(Choreographer.java:725)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:951)
at android.os.Handler.handleCallback(Handler.java:883)
at android.os.Handler.dispatchMessage(Handler.java:100)
at android.os.Looper.loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:7356)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)
V/MediaHTTPService: MediaHTTPService(android.media.MediaHTTPService@969a5ef): Cookies: null
D/EGL_emulation: eglMakeCurrent: 0xe331a180: ver 3 0 (tinfo 0xe330f830)
V/MediaHTTPService: makeHTTPConnection: CookieHandler (java.net.CookieManager@abffe09) exists.
V/MediaHTTPService: makeHTTPConnection(android.media.MediaHTTPService@969a5ef): cookieHandler: java.net.CookieManager@abffe09 Cookies: null
D/EGL_emulation: eglMakeCurrent: 0xe331a180: ver 3 0 (tinfo 0xe330f830)
D/EGL_emulation: eglMakeCurrent: 0xe331a180: ver 3 0 (tinfo 0xe330f830)
W/MediaHTTPConnection: readAt 516238 / 32768 => java.net.ProtocolException
E/MediaPlayerNative: error (1, -2147483648)
E/MediaPlayer: Error (1,-2147483648)
我不知道如何调试它。 是否有可能捕获这些错误,禁用警报,然后静默重试?
如果我在浏览器中打开 url,视频会完美加载和播放。
试试这个
Uri uri= Uri.parse(Environment.getExternalStorageDirectory().getAbsolutePath()+"/yourvideopath");
videoView.setVideoURI(uri);
videoView.start();
您可以使用它来获取存储在外部存储中的视频的路径。 将“/yourvideopath”替换为您的视频路径,例如 /dcim/camera/mov_bbb.mp4
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.