【问题标题】:how to make flutter video player responsive?如何使颤振视频播放器响应?
【发布时间】:2021-10-28 18:24:10
【问题描述】:

我试图制作一个默认播放视频的网页,但在全屏 看起来不错,但在更改大小时它变得最差。喜欢这张图片如何解决这个问题

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:
                                        
                           
                               

【问题讨论】:

    标签: flutter flutter-layout flutter-dependencies flutter-web flutter-animation


    【解决方案1】:

    您将 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

    【讨论】:

    • 我两个都做了,没有任何改变
    猜你喜欢
    • 2021-09-13
    • 2021-04-03
    • 2020-06-13
    • 1970-01-01
    • 2020-03-02
    • 1970-01-01
    • 2021-08-16
    • 1970-01-01
    • 2023-03-08
    相关资源
    最近更新 更多