【问题标题】:Media Controller never show on Video View媒体控制器从不显示在视频视图上
【发布时间】:2014-09-18 23:37:34
【问题描述】:

我搜索了许多具有相同答案的主题,

但看起来对我和很多人都不起作用。

Create Custom Media Controller

public class CcMediaController extends MediaController {

ImageButton mCCBtn;
Context mContext;
AlertDialog mLangDialog;

public CcMediaController(Context context) {
    super(context);
    mContext = context;
}

@Override
public void setAnchorView(View view) {
    super.setAnchorView(view);

    FrameLayout.LayoutParams frameParams = new FrameLayout.LayoutParams(
            LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    frameParams.gravity = Gravity.RIGHT|Gravity.TOP;

    View v = makeCCView();
    addView(v, frameParams);
}

private View makeCCView() {
    mCCBtn = new ImageButton(mContext);
    mCCBtn.setImageResource(R.drawable.abc_ab_bottom_solid_dark_holo);

    mCCBtn.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            Builder builder = new AlertDialog.Builder(mContext);
            builder.setSingleChoiceItems(R.array.array, 0, new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialog, int which) {
                    //Save Preference and Dismiss the Dialog here
                    Toast.makeText(mContext, "Which ::: "+which, Toast.LENGTH_LONG).show();
                }

            });
            mLangDialog = builder.create();
            mLangDialog.show();
        }
    });

    return mCCBtn;
}
}

Put Custom Media Controller into Video View by using setAnchorView()

CcMediaController mMc = new CcMediaController(this);

// FrameLayout.LayoutParams lp = new FameLayout.LayoutParams(
// FrameLayout.LayoutParams.MATCH_PARENT, 
// FrameLayout.LayoutParams.WRAP_CONTENT);
// lp.gravity = Gravity.BOTTOM;
// mMc.setLayoutParams(lp);
//
// ((ViewGroup) mMc.getParent()).removeView(mMc);
//
// (new VideoControllerView(this)).addView(mMc);

        // set play video view dialog details photo
        mMc.setAnchorView(mVvPlayVideoInDetail);
        mMc.setMediaPlayer(mVvPlayVideoInDetail);

        mVvPlayVideoInDetail.requestFocus();
        mVvPlayVideoInDetail.setBackgroundColor(Color.WHITE);
        mVvPlayVideoInDetail.setMediaController(mMc);
        mVvPlayVideoInDetail.setZOrderOnTop(true);

VideoView.xml

<VideoView
            android:alpha="0.5"
            android:background="@android:color/transparent"
            android:id="@+id/vv_play_video_dialog_detail"
            android:layout_height="250dp"
            android:layout_width="match_parent"
            android:layout_weight="1"
            android:visibility="visible"
            />

我将视频视图显示为高度 = 240dp 的对话框的一部分,而不是全屏。

还是不行,

请帮助我如何show Media Controller on Video View correctly

谢谢

【问题讨论】:

    标签: android media android-mediaplayer android-videoview mediacontroller


    【解决方案1】:

    尝试拨打setZOrderMediaOverlay(true); 这是由于setzorderontop(true) 无法在视频视图中显示视图,因此调用setZOrderMediaOverlay(true); 将覆盖setzorderontop(true)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-09-19
      • 1970-01-01
      相关资源
      最近更新 更多