没有ExoPlayer的Google Leanback showcase视频播放器
带有ExoPlayer的Google Leanback showcase视频播放器
我已经尝试了Google的leanback展示柜,它也以“适合屏幕显示”模式播放视频,并且两侧带有黑条。我也找不到在API文档的任何位置更改缩放模式的选项
答案 0 :(得分:0)
我不得不调查VideoFragment
来源以弄清楚这一点。 VideoFragment
有一个简单的SurfaceView
作为其布局的根元素,您要做的就是使SurfaceView
与父级(即设备屏幕)的宽度和高度匹配。为此,只需覆盖onVideoSizeChanged
并使用getSurfaceView
获取对SurfaceView
中使用的程序包专用VideoFragment
实例的引用。
@Override
protected void onVideoSizeChanged(int width, int height) {
switch (scaleMode) {
//Flag indicates that this video should stretch to screen
case MediaMetaData.SCALE_MODE_STRETCH:
View rootView = getView();
SurfaceView surfaceView = getSurfaceView();
ViewGroup.LayoutParams params = surfaceView.getLayoutParams();
params.height = rootView.getHeight();
params.width = rootView.getWidth();
surfaceView.setLayoutParams(params);
break;
//When the video shouldn't stretch, just invoke super to have the VideoFragment's default behavior which is fit to screen
default:
super.onVideoSizeChanged(width, height);
}
}