Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/206.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
java.io.IOException:setDataSource失败_Java_Android_Video_Video Streaming_Android Fullscreen - Fatal编程技术网

java.io.IOException:setDataSource失败

java.io.IOException:setDataSource失败,java,android,video,video-streaming,android-fullscreen,Java,Android,Video,Video Streaming,Android Fullscreen,我正在尝试使用FullscreenVideoView播放视频,但每次尝试播放存储的视频时都会出现此错误 Java.io.IOException: setDataSource failed. File n = new File(getApplicationContext().getFilesDir()+"/Downloads/video9.mp4"); Log.e(TAG, "URL:" + n); fullscreenVideoView.videoFil

我正在尝试使用FullscreenVideoView播放视频,但每次尝试播放存储的视频时都会出现此错误

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上的应用程序上运行代码,则必须在运行时请求权限。在您的情况下,它们将是:
读取外部存储
写入外部存储

尝试使用
视频文件(n.getAbsolutePath())
@DineshShingadiya相同错误:/fullscreenVideoView中应生成异常。因此,请发布fullscreenVideoView的代码。@如果fullscreenVideoView的完整代码正确,则该文件不存在……因此,我将该文件移动到原始文件夹中,但仍然收到相同的错误exist false;文件n=新文件(“android.resource://”+getPackageName()+“/”+R.raw.vid);