【问题标题】:How to play HTTP live stream on IOS device with Flutter APP?如何使用 Flutter APP 在 IOS 设备上播放 HTTP 直播?
【发布时间】:2020-01-12 05:09:08
【问题描述】:

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

我在 ChewieVideo_player 插件上进行了测试。它在 Android 上运行良好,但在 IOS 设备上不可用。不幸的是,调试控制台是空的...... Here is working .m3u8 file我试着玩了。

这是一个简单的复制器:

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

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

【问题讨论】:

  • 您好,您找到解决方案了吗?
  • 你找到解决办法了吗?

标签: ios flutter dart


【解决方案1】:

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

【讨论】:

    【解决方案2】:

    问题出在:

    if ([self duration] == 0) {
              return;
            }
    

    它在平台级别 FLTVideoPlayerPlugin.m 。第 325 行。直播视频的持续时间似乎为零。如果您删除那部分代码,它应该可以工作。

    【讨论】:

      猜你喜欢
      • 2013-12-02
      • 1970-01-01
      • 1970-01-01
      • 2022-07-07
      • 1970-01-01
      • 2017-10-24
      • 2015-05-28
      • 2020-01-05
      • 2012-03-22
      相关资源
      最近更新 更多