Android('无法播放此视频'; MediaPlayer和VideoView错误1 -38)

宝剑锋从磨砺出,梅花香自苦寒来。这篇文章主要讲述Android:' 无法播放此视频' ; MediaPlayer和VideoView错误1 -38相关的知识,希望能为你提供帮助。
我尝试使用下面的代码播放视频。但是,我在运行时遇到了“无法播放此视频”弹出的经典错误。我在搜索android文献和查看其他人的问题时做了尽职调查,但我似乎无法找到问题a)因为在文档中我没有找到MediaPlayer的错误代码(1,-38)和b)我的视频符合Android媒体格式(h.264和MPEG-4)所需的规范。如果有人能帮我指出正确的方向,我真的很感激!谢谢

private void startVideo() { Log.v(TAG, "videoUrl = " + mVideoUrl); Uri uri = Uri.parse(mVideoUrl); mVideo = (VideoView) getView().findViewById(R.id.preview_videoView); MediaController mediaController = new MediaController(getActivity()); mediaController.setAnchorView(mVideo); mVideo.setMediaController(mediaController); mVideo.setVideoURI(uri); mVideo.start(); }

这些是日志
10-07 21:08:38.5299986-9986/com.trainwithtanya.hiitandroid V/﹕ videoUrl = http://files.parsetfss.com/2bb9a4a0-9f35-4124-a634-d2fa7f8b165e/tfss-ca535209-4b4c-4022-95b8-8f011ed41daf-High%20Knees.mp4 10-07 21:08:38.5799986-10011/com.trainwithtanya.hiitandroid W/EGL_emulation﹕ eglSurfaceAttrib not implemented 10-07 21:08:38.5799986-10011/com.trainwithtanya.hiitandroid W/OpenGLRenderer﹕ Failed to set EGL_SWAP_BEHAVIOR on surface 0xa5245c20, error=EGL_SUCCESS 10-07 21:08:38.6099986-9986/com.trainwithtanya.hiitandroid D/MediaPlayer﹕ Couldn't open file on client side, trying server side 10-07 21:08:39.5829986-9986/com.trainwithtanya.hiitandroid D/MediaPlayer﹕ getMetadata 10-07 21:08:39.6379986-9999/com.trainwithtanya.hiitandroid E/MediaPlayer﹕ error (1, -38) 10-07 21:08:39.6379986-9986/com.trainwithtanya.hiitandroid E/MediaPlayer﹕ Error (1,-38) 10-07 21:08:39.6379986-9986/com.trainwithtanya.hiitandroid D/VideoView﹕ Error: 1,-38 10-07 21:08:39.6509986-10000/com.trainwithtanya.hiitandroid E/MediaPlayer﹕ error (1, -38) 10-07 21:08:39.7029986-9986/com.trainwithtanya.hiitandroid E/MediaPlayer﹕ Error (1,-38) 10-07 21:08:39.7029986-9986/com.trainwithtanya.hiitandroid D/VideoView﹕ Error: 1,-38

这是视频格式http://i288.photobucket.com/albums/ll185/akhan007/mediaType_zpsjfvfdpto.png
答案我想,你需要在mVideo.start(); 里面调用onPrepare
mVideo.setOnPreparedListener(new MediaPlayer.OnPreparedListener() { public void onPrepared(MediaPlayer mp) { mVideo.start(); } });

另一答案【Android(' 无法播放此视频' ; MediaPlayer和VideoView错误1 -38)】重启设备后,此问题已解决。

    推荐阅读