尝试创建小的视频表面或视频视图,并可以通过显示矩阵更改视图参数
DisplayMetrics displaymetrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(displaymetrics);
int height = displaymetrics.heightPixels;
int width = displaymetrics.widthPixels;
android.widget.FrameLayout.LayoutParams params = (android.widget.FrameLayout.LayoutParams) videoSurface.getLayoutParams();
params.width = width;
params.height=height-80;// -80 for android controls
params.setMargins(0, 0, 0, 50);
因此,要执行此代码,您可以创建自己的自定义媒体控制器,也可以通过扩展媒体控制器来使用设置锚点。
1)这是自定义媒体控制器链接
自定义媒体控制器
2)扩展媒体控制器并设置锚标签
设置锚标签
public void setAnchorView(final View view) {
super.setAnchorView(view);
Button fullScreen = new Button(context);
fullScreen.setText("FullScreen");
Log.e("media controller","Set anchorView");
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
params.setMargins(view.getWidth(), 0, 5, 20);
params.gravity = Gravity.RIGHT;
addView(fullScreen, params);
fullScreen.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
Log.e("media controller","full screen onclick");
Intent i = new Intent("xyxyxyxhx");
context.sendBroadcast(i);
}
});
}