gpt4 book ai didi

flutter - 如何在 Flutter 上播放 M3U8 格式的 Android 和 iOS

转载 作者:行者123 更新时间:2023-12-03 17:02:36 39 4
gpt4 key购买 nike

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

我试过这些插件;

  • video_player(无法播放)
  • flutter_simple_video_player(仅支持安卓)
  • 最佳答案

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

    关于flutter - 如何在 Flutter 上播放 M3U8 格式的 Android 和 iOS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57682604/

    39 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com