2 回复
关于Flutter直播的视频教程:https://www.itying.com/goods-1120.html
更多关于flutter如何实现拉流直播的实战系列教程也可以访问 https://www.itying.com/category-92-b0.html
Flutter中实现直播
Flutter中实现直播的话,我们可以使用第三方插件flutter_ijkplayer来实现。
https://pub.dev/packages/flutter_ijkplayer
1、安装依赖
dependencies:
flutter_ijkplayer: ^0.3.5+1
2、引入插件
import 'package:flutter_ijkplayer/flutter_ijkplayer.dart';
3、实例化IjkMediaController
IjkMediaController controller = IjkMediaController();
4、设置拉流地址
@override
void initState() {
super.initState();
this.initPlayer();
}
initPlayer() async{
await controller.setNetworkDataSource(
'http://192.168.0.11:8000/live/itying.flv',
autoPlay: false);
print("set data source success");
}
5、定义视频播放组件
Widget buildIjkPlayer() {
return Container(
height: 200, // 设置高度
child: IjkPlayer(
mediaController: controller
),
);
}
6、销毁
@override
void dispose() {
controller.dispose();
super.dispose();
}