コード例 #1
0
  /**
   * 构造函数
   *
   * @param context
   * @param attrs
   * @param defStyle
   */
  public VDVideoView(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    VDApplication.getInstance().setContext(context);
    mContext = context;
    setBackgroundColor(0x0);

    registerController(context);

    TypedArray typedArr =
        context.obtainStyledAttributes(attrs, R.styleable.VDVideoView, defStyle, 0);
    initLayer(typedArr);
    typedArr.recycle();
    init();

    if (mVideoView == null) {
      mVideoView = VDVideoViewController.create(context);
      VDVideoViewController cnotroller = VDVideoViewController.getInstance(context);
      if (cnotroller != null) cnotroller.setContext(context);
      initVideo();
    }

    if (((View) mVideoView).getParent() == null) {
      addVideoView(mVideoView);
    }
  }
コード例 #2
0
  /**
   * 构造函数,这种情况下,无法自动加载xml<br>
   * 适用于手动加载的情况下,new完毕后,使用:setLayers 函数来加载响应的layer
   *
   * @param context
   */
  public VDVideoView(Context context) {
    super(context);
    VDApplication.getInstance().setContext(context);
    mContext = context;
    setBackgroundColor(0x0);

    registerController(context);
    init();

    if (mVideoView == null) {
      mVideoView = VDVideoViewController.create(context);
      VDVideoViewController controller = VDVideoViewController.getInstance(context);
      if (controller != null) controller.setContext(context);
      initVideo();
    }

    if (((View) mVideoView).getParent() == null) {
      addVideoView(mVideoView);
    }
  }