I have VideoView instance. I need to know video source path from it.
Is it possible? Can anybody help me?
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();
}
}
}
How to get video source path fron video object ?
VideoView
doesn't have getters for video path/Uri. Your only chance 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) {}
Just bear in mind that a private field might be subject to change in future Android releases.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With