如何使用 Flutter APP 在 IOS 设备上播放 HTTP 直播流?

And*_*nyy 6 ios dart flutter

我正在寻找在 Flutter 中播放视频直播的方法。

我在ChewieVideo_player插件上进行了测试。它在 Android 上运行良好,但不适用于 IOS 设备。不幸的是,调试控制台是空的...... 这是我尝试播放的工作 .m3u8 文件

这是一个简单的复制器:

import 'package:video_player/video_player.dart';
import 'package:flutter/material.dart';

void main() => runApp(VideoApp());

class VideoApp extends StatefulWidget {
  @override
  _VideoAppState createState() => _VideoAppState();
}

class _VideoAppState extends State<VideoApp> {
  VideoPlayerController _controller;

  @override
  void initState() {
    super.initState();
    _controller = VideoPlayerController.network(
      'https://streamvideo.luxnet.ua/news24/smil:news24.stream.smil/playlist.m3u8')
        ..addListener(() {
          if (_controller.value.initialized) {
            print(_controller.value.position);
          }
        })
      ..initialize().then((_) {
        // Ensure the first frame is shown after the video is initialized, even before the play button has been pressed.
        setState(() {});
      });
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Video Demo',
      home: Scaffold(
        body: Center(
          child: Stack(
            children: <Widget>[
              _controller.value.initialized
              ? AspectRatio(
            aspectRatio: _controller.value.aspectRatio,
            child: VideoPlayer(_controller),
          )
              : Container()
            ],
          )
        ),
        floatingActionButton: FloatingActionButton(
          backgroundColor: Colors.orange,
          onPressed: () {
            setState(() {
              _controller.value.isPlaying
                  ? _controller.pause()
                  : _controller.play();
            });
          },
          child: Icon(
            _controller.value.isPlaying ? Icons.pause : Icons.play_arrow,
          ),
        ),
      ),
    );
  }

  @override
  void dispose() {
    super.dispose();
    _controller.dispose();
  }
}
Run Code Online (Sandbox Code Playgroud)

也许有人有使用 Flutter 在 IOS 上播放视频流的经验?非常感谢!

jax*_*ire 0

video_player插件目前不支持iOS模拟器。您的代码可能在物理设备上正常运行。