我正在使用这段代码在我的应用程序中添加背景全屏视频,它在虚拟设备上运行良好,但在物理设备上效果不佳!
new Flex(direction: Axis.vertical, children: <Widget>[
FittedBox(
fit: BoxFit.fill,
child: SizedBox(
width: controller.value.size?.width ?? 0,
height: controller.value.size?.height ?? 0,
child: VideoPlayer(controller)),
),
]),
发布于 2020-08-19 15:59:37
这对我很有效
SizedBox.expand(
child: FittedBox(
fit: BoxFit.cover,
child: SizedBox(
width: videoController.value.size?.width ?? 0,
height: videoController.value.size?.height ?? 0,
child: VisibilityDetector(
key: ObjectKey(videoController),
onVisibilityChanged: (visibility) {
if (visibility.visibleFraction == 0 && this.mounted) {
videoController.pause();
} else if (visibility.visibleFraction == 1) {
videoController.play();
}
},
child: VideoPlayer(videoController)),
)),
),
https://stackoverflow.com/questions/63489126
复制