本文介绍了如何获得HTML5视频的URI HTML5VFullScreen $ SurfaceVideoView在Android 4.0的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想,当用户点击了视频控制栏上的全屏按钮来获得一个HTML5视频的URI。据<一href="http://grep$c$c.com/file/repository.grep$c$c.com/java/ext/com.google.android/android/4.0.1_r1/android/webkit/HTML5VideoFullScreen.java">this,在Android 4.0的HTML5视频的看法是一个SurfaceView,而不是VideoView。

有人能告诉我怎么走SurfaceVideoView的URI?这是我的code。非常感谢。

  webView.setWebChromeClient(新WebChromeClient(){
  @覆盖
  公共无效onShowCustomView(查看视图,CustomViewCallback回调){
    super.onShowCustomView(查看,回调);
    如果(查看的instanceof的FrameLayout){
      最后的FrameLayout帧=(的FrameLayout)视图;
      如果(frame.getFocusedChild()的instanceof SurfaceView){
        SurfaceView视频=(SurfaceView)frame.getFocusedChild();
      }
    }
  });
 

解决方案

很简单,用反射。把 onShowCustomView()法这里面的:

  android.net.Uri穆里= NULL;

尝试
{
    @燮pressWarnings(rawtypes)
    类_VideoSurfaceView_Class_ =的Class.forName(android.webkit.HTML5VideoFullScreen $ VideoSurfaceView);

    java.lang.reflect.Field中_HTML5VideoFullScreen_Field_ = _VideoSurfaceView_Class_.getDeclaredField(本$ 0);

    _HTML5VideoFullScreen_Field_.setAccessible(真正的);

    对象_HTML5VideoFullScreen_Instance_ = _HTML5VideoFullScreen_Field_.get(((的FrameLayout)视图).getFocusedChild());

    @燮pressWarnings(rawtypes)
    类_HTML5VideoView_Class_ = _HTML5VideoFullScreen_Field_.getType()getSuperclass之()。

    java.lang.reflect.Field中_mUri_Field_ = _HTML5VideoView_Class_.getDeclaredField(穆里);

    _mUri_Field_.setAccessible(真正的);

    穆里=(URI)_mUri_Field_.get(_HTML5VideoFullScreen_Instance_);
}
赶上(例外前)
{
}

如果(穆里!= NULL)
{
    //有你有,穆里是视频的URI
}
 

I am trying to get a HTML5 video URI when the user clicks the fullscreen button in the video control bar. According to this, the HTML5 video view in Android 4.0 is a SurfaceView, not a VideoView.

Could someone tell me how to get the URI in SurfaceVideoView? This is my code. Thanks a lot.

webView.setWebChromeClient(new WebChromeClient(){
  @Override
  public void onShowCustomView(View view, CustomViewCallback callback) {
    super.onShowCustomView(view, callback);
    if (view instanceof FrameLayout){
      final FrameLayout frame = (FrameLayout) view;
      if (frame.getFocusedChild() instanceof SurfaceView){
        SurfaceView video= (SurfaceView) frame.getFocusedChild();
      }
    }
  });
解决方案

Easy, using reflection. Put this inside of the onShowCustomView() method:

android.net.Uri mUri = null;

try
{
    @SuppressWarnings("rawtypes")
    Class _VideoSurfaceView_Class_ = Class.forName("android.webkit.HTML5VideoFullScreen$VideoSurfaceView");

    java.lang.reflect.Field _HTML5VideoFullScreen_Field_ = _VideoSurfaceView_Class_.getDeclaredField("this$0");

    _HTML5VideoFullScreen_Field_.setAccessible(true);

    Object _HTML5VideoFullScreen_Instance_ = _HTML5VideoFullScreen_Field_.get(((FrameLayout) view).getFocusedChild());

    @SuppressWarnings("rawtypes")
    Class _HTML5VideoView_Class_ = _HTML5VideoFullScreen_Field_.getType().getSuperclass();

    java.lang.reflect.Field _mUri_Field_ = _HTML5VideoView_Class_.getDeclaredField("mUri");

    _mUri_Field_.setAccessible(true);

    mUri =  (Uri) _mUri_Field_.get(_HTML5VideoFullScreen_Instance_);
}
catch (Exception ex)
{   
}

if (mUri != null)
{
    // There you have, mUri is the URI of the video
}

这篇关于如何获得HTML5视频的URI HTML5VFullScreen $ SurfaceVideoView在Android 4.0的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-29 12:36