gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-01 15:28:43 25 4
gpt4 key购买 nike

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

我在 Chewie 上测试过和 Video_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_player 插件目前不支持 iOS 模拟器。您的代码可能在物理设备上正常运行。

关于ios - 如何使用 Flutter APP 在 IOS 设备上播放 HTTP 直播流?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57870851/

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