red5pro 0.0.5 copy "red5pro: ^0.0.5" to clipboard
red5pro: ^0.0.5 copied to clipboard

outdated

Red5Pro Streaming & Player

red5pro #

Red5Pro Streaming & Player

Red5Pro Plugin that supports Red5Pro Streaming & Player.

Installation #

add red5pro to your pubspec.yaml

  1. Add the following key/value pair to your app's Info.plist (for iOS):

    <plist version="1.0">
    <dict>
        ...
        <key>NSCameraUsageDescription</key>
        <string>Camera Usage</string>
        <key>NSMicrophoneUsageDescription</key>
        <string>Microphone Usage</string>
        <key>NSPhotoLibraryAddUsageDescription</key>
        <string>Photo Usage</string>
        <key>NSPhotoLibraryUsageDescription</key>
        <string>Photo Usage</string>
    </dict>
    </plist>
    
  2. Add the following <uses-permissions> tags to your app's AndroidManifest.xml (for Android):

    <manifest xmlns:android="http://schemas.android.com/apk/res/android" ...>
        <uses-permission android:name="android.permission.CAMERA" />
        <uses-permission android:name="android.permission.RECORD_AUDIO" />
        <uses-permission android:name="android.permission.INTERNET" />
        <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
        <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
        <uses-permission android:name="android.permission.READ_PHONE_STATE" />
        <uses-permission android:name="android.permission.CAPTURE_AUDIO_OUTPUT" />
        <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
        <application ...>
        ...
    
  3. The following Proguard Rules may be required when deploying an Android App Release with minification:

    -keepattributes *Annotation*,Signature,EnclosingMethod
    -keep class com.red5pro.** { *; }
    -keep interface com.red5pro.** { *; }
    -keep public class com.red5pro.streaming.** { *; }
    -dontwarn com.red5pro.**
    -keep, includedescriptorclasses class com.red5pro.streaming.R5Stream { *; }
    -keep, includedescriptorclasses class com.android.webrtc.audio.** { *; }
    

REQUEST PERMISSION BEFORE STREAMING OR PLAYING #

Future<bool> _hasPermissions() async {
    Map<Permission, PermissionStatus> statuses = await [
      Permission.camera,
      Permission.microphone,
      Permission.storage,
      Permission.phone,
    ].request();
    return statuses.entries
        .where((element) =>
            element.value == PermissionStatus.denied ||
            element.value == PermissionStatus.permanentlyDenied)
        .isEmpty;
  }

FOR STREAMING #

Red5Configuration config = Red5Configuration(
    licenseKey: 'RED5PRO_LICENSE_KEY',
    protocol: R5StreamProtocol.RTSP,
    host: 'YOUR_HOST',
    port: 'HOST_PORT');

late R5StreamViewController r5streamViewController;

Red5StreamView(
    red5configuration: config,
    onR5StreamViewCreated: (controller) {
      r5streamViewController = controller;
    },
  );

// For Start Streaming

r5streamViewController.startStreaming('STREAM_NAME', RecordType.Live);

// For Stop Streaming

r5streamViewController.stopStreaming();

FOR STREAM PLAYER #

Red5Configuration config = Red5Configuration(
    licenseKey: 'RED5PRO_LICENSE_KEY',
    protocol: R5StreamProtocol.RTSP,
    host: 'YOUR_HOST',
    port: 'HOST_PORT');

late R5StreamPlayerViewController controller;

Red5StreamPlayerView(
      red5configuration: config,
      streamName: 'STREAM_NAME',
      onR5StreamPlayerViewCreated: (controller) {
        this.controller = controller;
      },
    );

// For Start Playing

controller.play();

// For Stop Playing

controller.stop();