当前位置: 代码迷 >> 综合 >> Flutter videoplayer chewie 视频播放自动识别横版竖版视频
  详细解决方案

Flutter videoplayer chewie 视频播放自动识别横版竖版视频

热度:59   发布时间:2023-09-14 17:23:31.0

秉承着看得懂就看看不懂就问的原则,直接上代码

import 'package:chewie/chewie.dart';
import 'package:connectivity/connectivity.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:midou_ee/mall/mall_router.dart';
import 'package:midou_ee/routers/navigator_util.dart';
import 'package:video_player/video_player.dart';class GoodVideoWidget extends StatefulWidget {final String video;GoodVideoWidget({Key key, this.video}) : super(key: key);@override_GoodVideoWidgetState createState() => _GoodVideoWidgetState();
}class _GoodVideoWidgetState extends State<GoodVideoWidget> {Widget playerWidget;VideoPlayerController _controller;// bool _isPlaying = false;String url = '';@overridevoid initState() {super.initState();_controller = VideoPlayerController.network(widget.video)..initialize().then((_) {setState(() {});});}@overrideWidget build(BuildContext context) {return Container(height: 400.0,color: Colors.grey,child:_controller.value.initialized? Chewie(controller: ChewieController(videoPlayerController: _controller,aspectRatio: _controller.value.aspectRatio,autoPlay: false,looping: false,),):SizedBox(),);}
}
  相关解决方案