java.io.IOException: setDataSource failed



我正在尝试使用全屏视频视图播放视频,但每次尝试播放存储的视频时都会收到此错误

Java.io.IOException: setDataSource failed.
 File n  = new File(getApplicationContext().getFilesDir()+"/Downloads/video9.mp4");
        Log.e(TAG, "URL:" + n); 
        fullscreenVideoView.videoFile(n).enableAutoStart().fastForwardSeconds(5)
                .rewindSeconds(5)
                .addSeekBackwardButton()
                .addSeekForwardButton();

有很多原因,为什么你的数据源不起作用。尝试添加日志记录:

 File n  = new File(getApplicationContext().getFilesDir()+"/Downloads/video9.mp4");
        Log.e(TAG, "URL:" + n); 
        Log.e(TAG, "exists: " + n.exists());
        fullscreenVideoView.videoFile(n).enableAutoStart().fastForwardSeconds(5)
                .rewindSeconds(5)
                .addSeekBackwardButton()
                .addSeekForwardButton();

可能文件不存在。这可能是因为未授予权限或文件方式错误。

起初,我会建议您检查权限。如果您在 6+ android 上的应用程序上运行代码,则必须在运行时请求权限。在您的情况下,它们将是:READ_EXTERNAL_STORAGEWRITE_EXTERNAL_STORAGE

最新更新