flutter实现视频播放

编程入门 行业动态 更新时间:2024-10-26 10:41:05

flutter实现<a href=https://www.elefans.com/category/jswz/34/1770074.html style=视频播放"/>

flutter实现视频播放

使用到的库是lecle_yoyo_player

详细请查看文档

main.dart代码如下:

import 'package:flutter/material.dart';
import 'package:lecle_yoyo_player/lecle_yoyo_player.dart';void main() => runApp(const MyApp());class MyApp extends StatefulWidget {const MyApp({Key? key}) : super(key: key);@override_MyAppState createState() => _MyAppState();
}class _MyAppState extends State<MyApp> {bool fullscreen = false;@overrideWidget build(BuildContext context) {return MaterialApp(debugShowCheckedModeBanner: false,title: 'Material App',home: Scaffold(appBar: fullscreen == false? AppBar(backgroundColor: Colors.blue,centerTitle: true,leading: IconButton(icon: const Icon(Icons.arrow_back),onPressed: () {Navigator.pop(context);},),): null,body: Padding(padding:fullscreen ? EdgeInsets.zero : const EdgeInsets.only(top: 32.0),child: YoYoPlayer(aspectRatio: 16 / 10,url:// '.webm',// ".mp4",//  "/x36xhzz/x36xhzz.m3u8",".m3u8",allowCacheFile: true,onCacheFileCompleted: (files) {print('Cached file length ::: ${files?.length}');if (files != null && files.isNotEmpty) {for (var file in files) {print('File path ::: ${file.path}');}}},onCacheFileFailed: (error) {print('Cache file error ::: $error');},videoStyle: const VideoStyle(qualityStyle: TextStyle(fontSize: 16.0,fontWeight: FontWeight.w500,color: Colors.white,),forwardAndBackwardBtSize: 30.0,playButtonIconSize: 40.0,playIcon: Icon(Icons.play_circle,size: 40.0,color: Colors.white,),pauseIcon: Icon(Icons.pause_circle,size: 40.0,color: Colors.white,),videoQualityPadding: EdgeInsets.all(5.0),// showLiveDirectButton: true,// enableSystemOrientationsOverride: false,),videoLoadingStyle: const VideoLoadingStyle(loading: Center(child: Column(mainAxisAlignment: MainAxisAlignment.center,crossAxisAlignment: CrossAxisAlignment.center,children: [Icon(Icons.local_dining),SizedBox(height: 16.0),Text("Loading video..."),],),),),onFullScreen: (value) {setState(() {if (fullscreen != value) {fullscreen = value;}});},),),),);}
}

更多推荐

flutter实现视频播放

本文发布于:2023-11-15 23:20:05,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1609152.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:视频播放   flutter

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!