我使用Cloudflare将应用程序中的视频从mp4格式移到m3u8。我注意到,在iOS上,一些视频有错误的纵横比,看起来放大(在安卓系统上没有问题)。
我发现下面的线程https://github.com/flutter/flutter/issues/97206存在同样的问题,我理解的是使用video_player: 2.2.11版本,因为我现在拥有的是video_player: 2.2.7。我改变了版本,但这并没有解决问题。我现在也尝试了最新的版本,即video_player: 2.4.5,但仍然有同样的问题。
如果有人想办法解决这个问题,请告诉我。我被困住了,不知道如何进行调试。
发布于 2022-06-22 13:34:46
https://pub.dev/packages/chewie库将用于播放m3u8文件。
添加依赖项
dependencies:
chewie: ^latest_version代码片段:
import 'package:flutter/material.dart';
import 'package:chewie/chewie.dart';
import 'package:video_player/video_player.dart';
void main() {
runApp(MaterialApp(home: MyApp()));
}
class MyApp extends StatefulWidget {
@override
_MyAppState createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
final videoPlayerController = VideoPlayerController.network(
'url.m3u8');
ChewieController chewieController;
@override
void initState() {
// TODO: implement initState
super.initState();
chewieController = ChewieController(
videoPlayerController: videoPlayerController,
aspectRatio: 3 / 2,
autoPlay: true,
looping: true,
);
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text("Sample App"),
),
body: Container(
child: Chewie(controller: chewieController),
));
}
}https://stackoverflow.com/questions/72660307
复制相似问题