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出现在此处
我将问题追溯到androidMediaPlayer
(在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获取路径。内容提供商尚不支持远程异常。我怀疑媒体提供商会抛出某种异常