如何使颤振视频播放器响应?
how to make flutter video player responsive?
我试图制作一个默认播放视频但全屏播放的网页 it looks fine but when changing size it getting worst. Like this image how to fix this issue
class WelcomePage extends StatefulWidget {
VideoPlayerController? _videoCOntroller;
@override
void initState() {
super.initState();
_videoCOntroller!.initialize().then((value) {
_videoCOntroller!.play();
_videoCOntroller!.setLooping(true);
});
}
@override
Widget build(BuildContext context) {
final size = MediaQuery.of(context).size;
return Scaffold(
body: Column(
children: [
Stack(
children: [
Container(
color: Colors.amber,
height: size.height,
width: size.width,
child: FittedBox(
fit: BoxFit.cover,
child: Container(
height: size.height,
width: size.width,
child: VideoPlayer(_videoCOntroller!),
),
),
),
Positioned(
height: size.height,
width: size.width,
child:
child:
您将 size.width 设置为 Container 的高度而不是 size.height:
child: Container(
height: size.width,
width: size.width,
child: VideoPlayer(_videoCOntroller!),
),
如果更改不能解决您的问题。将 BoxFit.cover 更改为 BoxFit.fill。
编辑 1: 我认为这是一个错误。关于Android的问题会在video_player 2.1.6中解决,但不知道web的情况。您可能需要查看 this issue on github
问题是在列中使用堆栈,只是删除可能会解决问题
我试图制作一个默认播放视频但全屏播放的网页
class WelcomePage extends StatefulWidget {
VideoPlayerController? _videoCOntroller;
@override
void initState() {
super.initState();
_videoCOntroller!.initialize().then((value) {
_videoCOntroller!.play();
_videoCOntroller!.setLooping(true);
});
}
@override
Widget build(BuildContext context) {
final size = MediaQuery.of(context).size;
return Scaffold(
body: Column(
children: [
Stack(
children: [
Container(
color: Colors.amber,
height: size.height,
width: size.width,
child: FittedBox(
fit: BoxFit.cover,
child: Container(
height: size.height,
width: size.width,
child: VideoPlayer(_videoCOntroller!),
),
),
),
Positioned(
height: size.height,
width: size.width,
child:
child:
您将 size.width 设置为 Container 的高度而不是 size.height:
child: Container(
height: size.width,
width: size.width,
child: VideoPlayer(_videoCOntroller!),
),
如果更改不能解决您的问题。将 BoxFit.cover 更改为 BoxFit.fill。
编辑 1: 我认为这是一个错误。关于Android的问题会在video_player 2.1.6中解决,但不知道web的情况。您可能需要查看 this issue on github
问题是在列中使用堆栈,只是删除可能会解决问题