flutter_video_live_stream 1.0.3 copy "flutter_video_live_stream: ^1.0.3" to clipboard
flutter_video_live_stream: ^1.0.3 copied to clipboard

Flutter RTMP live stream client for your audio/video application. Maintained fork of apivideo_live_stream.

badge   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.

This is a maintained fork of the official api.video Flutter live stream plugin, which is no longer actively maintained. The original work is credited to api.video. The fork adds StreamPack 3.2.0 and AGP 9 built-in Kotlin on Android, 16 KB page-size support, and an SPM-based iOS SDK (HaishinKit 2.2.5).

Getting started #

Installation #

Run the following command at the root of your project:

flutter pub add flutter_video_live_stream

In your dart file, import the package:

import 'package:flutter_video_live_stream/flutter_video_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:realmastana/flutter_video_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.

iOS: Swift Package Manager #

The iOS implementation is distributed as a Swift package (no CocoaPods). It depends on a fork of the api.video iOS live stream SDK that was migrated to HaishinKit 2.2.5 and is distributed as a Swift package (the upstream SDK is CocoaPods-only and still pins HaishinKit 1.9.3, which crashes the Swift 6.3 compiler on Xcode 26 — the fork fixes both problems).

Requires Flutter 3.44+ (Swift Package Manager is the default iOS dependency manager since Flutter 3.44).

Checkout directory name requirement

Flutter derives the SwiftPM package identity from the plugin's path basename, and it must match the plugin name (flutter_video_live_stream). This matters when consuming this repository as a path dependency (including the example app):

git clone <this-repo-url> flutter_video_live_stream   # <- directory name matters!
cd flutter_video_live_stream/example
flutter build ios

Git dependencies (flutter_video_live_stream: {git: ...} in pubspec) are currently broken by a Flutter tooling limitation: pub clones into ~/.pub-cache/git/<repo>-<commit>/, and the commit suffix makes the package identity mismatch (unable to override package ... doesn't match override's identity). Use a path dependency instead, for example a git submodule checked out under a directory named flutter_video_live_stream:

git submodule add <this-repo-url> packages/flutter_video_live_stream
# pubspec.yaml
#   flutter_video_live_stream:
#     path: packages/flutter_video_live_stream

Plugins #

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

Plugin README
StreamPack StreamPack
HaishinKit HaishinKit

Support #

If this package helps you, consider buying me a coffee:

Buy me a coffee

FAQ #

If you have any questions, feel free to open an issue or reach out on GitHub / Twitter/X (@realmastana).

1
likes
160
points
156
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

Flutter RTMP live stream client for your audio/video application. Maintained fork of apivideo_live_stream.

Repository (GitHub)
View/report issues
Contributing

License

MIT (license)

Dependencies

flutter, json_annotation, meta, native_device_orientation, plugin_platform_interface, settings_ui

More

Packages that depend on flutter_video_live_stream

Packages that implement flutter_video_live_stream