如何在 Flutter 上播放 M3U8 格式 Android & iOS

How to Play M3U8 Format Android & iOS on Flutter

我在 iOS

上找不到 M3U8 Url 播放器的任何解决方案

我试过这些插件;

chewie lib 将用于播放 m3u8 文件

添加依赖项

dependencies:
  chewie: ^0.9.10

代码段:

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),
        ));
  }
}

YoYo player是个不错的选择。

  1. 添加依赖:

yoyo_player: #latest

  1. 随处使用:
 YoYoPlayer(
       aspectRatio: 16 / 9,
       url:  "",
       videoStyle: VideoStyle(),
       videoLoadingStyle: VideoLoadingStyle(),
  ),