Issue
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 ?
Solution
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.
Answered By - Tomik
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.