搜索插件、代码仓与 APP 分类

插件详情v1.2.0

apivideo_live_stream

适用于您音视频应用的 Flutter RTMP 直播流客户端。由 api.video 用心打造。

AndroidiOS
近 30 天下载
6690
喜欢数
99
Pub 分数
140

安装插件

flutter pub add apivideo_live_stream

插件介绍

基于插件公开信息、社区数据与项目使用情况整理的选型参考。

一个 Flutter RTMP 直播客户端,可在 Flutter 应用中实现实时音视频广播。由 api.video 用 ❤️ 构建,支持与 Android 和 iOS 上的直播工作流程无缝集成。该包通过使用 RTMP 协议简化了直播流的设置和管理,非常适合用于直播活动、网络研讨会或社交直播平台等互动应用。它为希望提供高质量、低延迟直播内容的开发者提供了可靠的基石。

适合场景

  • 实时事件直播
  • 网络研讨会流媒体
  • 社交媒体实时动态
  • 互动视频聊天
  • 实时内容共享

主要特点

  • RTMP 直播流支持
  • Android 和 iOS 兼容性
  • 与 api.video 的简单集成
  • 低延迟流媒体
  • 安全连接处理

适合对象

  • 开发实时视频应用的开发者
  • 使用 api.video 进行流媒体传输的团队
  • 需要实时音频/视频的应用程序
  • 初创公司推出实时功能
  • 以移动设备为先的流媒体解决方案

使用建议

  • 需要 api.video 帐户和 API 密钥
  • 限制为 RTMP 协议
  • 依赖稳定的互联网连接
  • 可能需要为自定义流设置进行额外配置
  • 不适用于非实时视频播放

原始 README

以下为关联源码仓库的 README 原文快照,最新内容请访问源码仓库。

badge   badge   badge

Flutter RTMP live stream client

api.video is the video infrastructure for product builders. Lightning fast video APIs for integrating, scaling, and managing on-demand & low latency live streaming features in your app.

Table of contents

Project description

This module is made for broadcasting RTMP live stream from smartphone camera.

Getting started

Installation

Run the following command at the root of your project:

flutter pub add apivideo_live_stream

In your dart file, import the package:

import 'package:apivideo_live_stream/apivideo_live_stream.dart';
Permissions

To be able to broadcast, you must:

  1. On Android: ask for internet, camera and microphone permissions:

<manifest>
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.RECORD_AUDIO" />
    <uses-permission android:name="android.permission.CAMERA" />
</manifest>

The library will require android.permission.CAMERA and android.permission.RECORD_AUDIO at runtime. You don't need to request them.

  1. On iOS: update the Info.plist with a usage description for camera and microphone

<key>NSCameraUsageDescription</key>
<string>Your own description of the purpose</string>
<key>NSMicrophoneUsageDescription</key>
<string>Your own description of the purpose</string>
Code sample
  1. Creates a live stream controller

final ApiVideoLiveStreamController _controller = ApiVideoLiveStreamController(
    initialAudioConfig: AudioConfig(), initialVideoConfig: VideoConfig.withDefaultBitrate());
  1. Initializes the live stream controller
await _controller.initialize();
  1. Adds a CameraPreview widget as a child of your view
@override
Widget build(BuildContext context) {
  return SizedBox(
      width: 300.0,
      height: 300.0,
      child: ApiVideoCameraPreview(controller: _controller));
}

ApiVideoCameraPreview parameters:

  • controller: the live stream controller
  • fit: the fit of the preview (default is BoxFit.contain, see BoxFit for more information)
  • child: a child widget to overlay on top of the preview (optional)
  1. Starts a live stream
_controller.startStreaming("YOUR_STREAM_KEY");
  1. Stops streaming and preview
_controller.stop();
Manage application lifecycle

On the application side, you must manage application lifecycle:

@override
void didChangeAppLifecycleState(AppLifecycleState state) {
  if (state == AppLifecycleState.inactive) {
    _controller.stop();
  } else if (state == AppLifecycleState.resumed) {
    _controller.startPreview();
  }
}

Example App

You can try our example app, feel free to test it.

Setup

Be sure to follow the Flutter installation steps before anything.

  1. Open Android Studio
  2. File > New > Project from Version Control

In URL field, type:

git@github.com:apivideo/api.video-flutter-live-stream.git

Wait for the indexation to finish.

Android

Connect an Android device to your computer and click on the Run main.dart button.

iOS
  1. Connect an iOS device to your computer and click on the Run main.dart button.

  2. The build will fail because you haven't set your development profile, sign your application:

Open Xcode, click on "Open a project or file" and open the YOUR_PROJECT_NAME/example/ios/Runner.xcworkspace file.
Click on Example, go in Signin & Capabilities tab, add your team and create a unique bundle identifier.

Plugins

api.video Flutter live stream library is using external native libraries:

Plugin README
StreamPack StreamPack
HaishinKit HaishinKit

FAQ

If you have any questions, ask us in the community or use issues.

所属分类

依赖

依赖清单 4 项

源码仓库

使用此插件的项目