I would like to play a video using VideoView
:
videoView.setVideoURI(Uri.parse("http://192.168.1.10:7777/mov_bbb.mp4"));
videoView.start();
It works randomly. 20% of the time the video is loaded, and it starts. But 80% of the time, I get this error:
Can't play this video
This is outputted to the console:
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)
I have no idea how to debug this. Is it possible to catch these errors, disable the alert, and just silently retry?
If I open the url in a browser, the video loads and plays perfectly.
Try this
Uri uri= Uri.parse(Environment.getExternalStorageDirectory().getAbsolutePath()+"/yourvideopath");
videoView.setVideoURI(uri);
videoView.start();
You can get the path of your video stored in external storage by using this. Replace "/yourvideopath" with your video path such as /dcim/camera/mov_bbb.mp4
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.