Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/solr/3.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 如何禁用android mediaplayer FileNotFoundException_Java_Android_Exception Handling_Android Mediaplayer - Fatal编程技术网

Java 如何禁用android mediaplayer FileNotFoundException

Java 如何禁用android mediaplayer FileNotFoundException,java,android,exception-handling,android-mediaplayer,Java,Android,Exception Handling,Android Mediaplayer,我有VideoView,它从http协议获取URI,这个URI对我来说是非常私有的,但是在setVideoURI中,系统抛出一个调试异常,如下所示: 07-06 10:35:10.920:D/MediaPlayer(7799):java.io.FileNotFoundException:无内容提供商:…我的私人url出现在此处 我将问题追溯到androidMediaPlayer(在VideoView中使用) 这就是setDataSource中发生的情况: public void setDataS

我有
VideoView
,它从http协议获取URI,这个URI对我来说是非常私有的,但是在
setVideoURI
中,系统抛出一个
调试异常
,如下所示:

07-06 10:35:10.920:D/MediaPlayer(7799):java.io.FileNotFoundException:无内容提供商:
…我的私人url出现在此处

我将问题追溯到android
MediaPlayer
(在
VideoView
中使用)

这就是setDataSource中发生的情况:

public void setDataSource(Context context, Uri uri)
        throws IOException, IllegalArgumentException, SecurityException, IllegalStateException {

        /****
            Test if URI is in assets, and of course HTTP (in my case) will not!
        ****/
        AssetFileDescriptor fd = null;
        try {
            ContentResolver resolver = context.getContentResolver();
            fd = resolver.openAssetFileDescriptor(uri, "r");
            if (fd == null) {
                return;

        } catch (SecurityException ex) {
        } catch (IOException ex) {
            /****
                Here is the exception which let me crazy :(
            ****/
        } finally {
            if (fd != null) {
                fd.close();
            }
        }

        /****
            So set HTTP here!
        ****/

        setDataSource(uri.toString());
        return;
 }
实际上,异常是在方法中抛出的

那么,在LogCat中防止此异常的建议方法是什么

这就是我尝试过的:

1-捕获
setVideoURI
异常

2-
使用ProGaurd AssumenisdeEffects类android.util.Log
,但这仅适用于应用程序上下文(MediaPlayer是系统上下文)


出于兼容性原因,我不建议使用覆盖系统类。

通过从设备上的DCIM文件夹获取文件来解决问题,但不要使用getContentResolver获取路径。内容提供商尚不支持远程异常。我怀疑媒体提供商会抛出某种异常