apivideo_live_stream

Creator: coderz1093

Last updated:

Add to Cart

Description:

apivideo live stream

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 #

Table of contents
Project description
Getting started

Installation
Permissions
Code sample

Manage application lifecycle




Example App

Setup

Android
iOS




Plugins
FAQ



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
copied to clipboard
In your dart file, import the package:
import 'package:apivideo_live_stream/apivideo_live_stream.dart';
copied to clipboard
Permissions #
To be able to broadcast, you must:

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>
copied to clipboard
The library will require android.permission.CAMERA and android.permission.RECORD_AUDIO at runtime.
You don't need to request them.

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>
copied to clipboard
Code sample #

Creates a live stream controller


final ApiVideoLiveStreamController _controller = ApiVideoLiveStreamController(
initialAudioConfig: AudioConfig(), initialVideoConfig: VideoConfig.withDefaultBitrate());
copied to clipboard

Initializes the live stream controller

await _controller.initialize();
copied to clipboard

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));
}
copied to clipboard
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)


Starts a live stream

_controller.startStreaming("YOUR_STREAM_KEY");
copied to clipboard

Stops streaming and preview

_controller.stop();
copied to clipboard
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();
}
}
copied to clipboard
Example App #
You can try
our example app,
feel free to test it.
Setup #
Be sure to follow the Flutter installation steps before
anything.

Open Android Studio
File > New > Project from Version Control

In URL field, type:
git@github.com:apivideo/api.video-flutter-live-stream.git
copied to clipboard
Wait for the indexation to finish.
Android
Connect an Android device to your computer and click on the Run main.dart button.
iOS


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


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.

License

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Customer Reviews

There are no reviews.