Android的获得VideoView视频源路径 [英] Android get Video source path from VideoView
本文介绍了Android的获得VideoView视频源路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有VideoView实例。我需要知道它从视频源的路径。
I have VideoView instance. I need to know video source path from it.
这可能吗?任何人可以帮助我吗?
Is it possible? Can anybody help me?
从WebChromeClient类我的code是:
My code from WebChromeClient class is:
@Override
public void onShowCustomView(final View view, final CustomViewCallback callback) {
super.onShowCustomView(view, callback);
if (view instanceof FrameLayout) {
final FrameLayout frame = (FrameLayout) view;
if (frame.getFocusedChild() instanceof VideoView) {
// get video view
video = (VideoView) frame.getFocusedChild();
}
}
}
如何获得视频源路径弗朗的视频对象?
推荐答案
VideoView没有为视频路径/乌里干将。你唯一的变化是使用反射。 URI是存储在私人乌里穆里
。要访问它,你可以使用:
VideoView doesn't have getters for video path/Uri. Your only change is to use reflection. The Uri is stored in private Uri mUri
. To access it you can use:
Uri mUri = null;
try {
Field mUriField = VideoView.class.getDeclaredField("mUri");
mUriField.setAccessible(true);
mUri = (Uri)mUriField.get(video);
} catch(Exception e) {}
只要记住一个私有字段可能会在将来的Android版本中更改。
Just bear in mind that a private field might be subject to change in future Android releases.
这篇关于Android的获得VideoView视频源路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文