我这边用的是ux的FPVWidget,界面有地图和视频切换功能,正常推流是没问题的,但是一旦点击地图,FPVWidget变小了之后,推流就没有视频流了,需要重新断流,重新推才行
已完成目前使用uk提供的demo来进行视频和地图的切换,具体如下。请问如何修改可以使视频流不中断
private void onViewClick(View view) {
if (view == fpvWidget && !isMapMini) {
resizeFPVWidget(RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT, 0, 0);
reorderCameraCapturePanel();
ResizeAnimation mapViewAnimation = new ResizeAnimation(mapWidget, deviceWidth, deviceHeight, width, height, margin);
mapWidget.startAnimation(mapViewAnimation);
isMapMini = true;
}
else if (view == mapWidget && isMapMini) {
//hidePanels();
resizeFPVWidget(width, height, margin, 12);
reorderCameraCapturePanel();
ResizeAnimation mapViewAnimation = new ResizeAnimation(mapWidget, width, height, deviceWidth, deviceHeight, 0);
mapWidget.startAnimation(mapViewAnimation);
isMapMini = false;
}
}
private void resizeFPVWidget(int width, int height, int margin, int fpvInsertPosition) {
RelativeLayout.LayoutParams fpvParams = (RelativeLayout.LayoutParams) primaryVideoView.getLayoutParams();
fpvParams.height = height;
fpvParams.width = width;
fpvParams.rightMargin = margin;
fpvParams.bottomMargin = margin;
if (isMapMini) {
fpvParams.addRule(RelativeLayout.CENTER_IN_PARENT, 0);
fpvParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT, RelativeLayout.TRUE);
fpvParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE);
} else {
fpvParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT, 0);
fpvParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, 0);
fpvParams.addRule(RelativeLayout.CENTER_IN_PARENT, RelativeLayout.TRUE);
}
primaryVideoView.setLayoutParams(fpvParams);
parentView.removeView(primaryVideoView);
parentView.addView(primaryVideoView, fpvInsertPosition);
}
private void reorderCameraCapturePanel() {
View cameraCapturePanel = findViewById(R.id.CameraCapturePanel);
parentView.removeView(cameraCapturePanel);
parentView.addView(cameraCapturePanel, isMapMini ? 9 : 13);
}
请先登录再写评论。
评论
3 条评论