zegoliveroom_plugin 1.2.12

  • Readme
  • Changelog
  • Example
  • Installing
  • 79

zegoliveroom_plugin pub package #

English | 中文

Zego's audio and video Flutter SDK provides live video and real-time audio and video services.

Learn more about the solution: https://www.zego.im

1️⃣ Download and Install Flutter #

Flutter Get Started #

2️⃣ Configuration development environment #

  • Android Studio: Preferences -> Plugins, search for the Flutter plugin to download, configure the first step to download the Flutter SDK path in the plugin.

  • VS Code: Search for the Flutter extension in the app store and download

After configuring the flutter environment in any of the above development environments, execute the flutter doctor on the command line and complete the related undownloaded dependencies according to the prompts.

3️⃣ Apply for ZEGO AppID #

Log in to ZEGO Official Website to register an account, select a scenario according to your actual business needs, and obtain AppID and App Sign for initializing the SDK.

4️⃣ Import zegoliveroom_plugin #

Open the pubspec.yaml in the project and add the zegoliveroom_plugin dependency:

dependencies:
  flutter:
    sdk: flutter

  zegoliveroom_plugin: ^1.2.12
  • Depends on git #

dependencies:
  flutter:
    sdk: flutter

  zegoliveroom_plugin:
    git:
      url: git://github.com/zegoim/zego-flutter-sdk.git
      ref: master

After saving the file, execute flutter pub get

5️⃣ Add device permissions #

Android #

Open the file app/src/main/AndroidManifest.xml, and add the following contents:

Add Android Privacy

    <!-- Permissions required by the SDK -->
    <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
    <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.CAMERA" />
    <uses-permission android:name="android.permission.BLUETOOTH" />
    <uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <!-- Permissions required by the App -->
    <uses-permission android:name="android.permission.READ_PHONE_STATE" />
    <uses-permission android:name="android.permission.WAKE_LOCK" />

    <uses-feature
        android:glEsVersion="0x00020000"
        android:required="true" />

    <uses-feature android:name="android.hardware.camera" />
    <uses-feature android:name="android.hardware.camera.autofocus" />

Note: Because Android 6.0 requires dynamic permissions for some of the more important permissions, you cannot apply for static permissions only through the AndroidMainfest.xml file. Therefore, you need to refer to the following code (requestPermissions is the Activity method)

String[] permissionNeeded = {
        "android.permission.CAMERA",
        "android.permission.RECORD_AUDIO"};

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
    if (ContextCompat.checkSelfPermission(this, "android.permission.CAMERA") != PackageManager.PERMISSION_GRANTED ||
        ContextCompat.checkSelfPermission(this, "android.permission.RECORD_AUDIO") != PackageManager.PERMISSION_GRANTED) {
        requestPermissions(permissionNeeded, 101);
    }
}

iOS #

Choose the option TARGETS -> Info -> Custom iOS Target Properties

Add iOS Privacy

Click the + Add button to add camera and microphone permissions.

  1. Privacy - Camera Usage Description

  2. Privacy - Microphone Usage Description

After adding permissions, it will be as shown:

Add iOS Privacy Done

If you use Platform View, you need to add an additional description for iOS, refer to FAQ-3

6️⃣ Init SDK #

import 'package:flutter/material.dart';
import 'package:zegoliveroom_plugin/zegoliveroom_plugin.dart';

void main() => runApp(new MyApp());

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => new _MyAppState();
}

class _MyAppState extends State<MyApp> {

  // Fill in the AppID actually obtained from the official website
  final int appID = 00000000;
  // Fill in the AppSign actually obtained from the official website
  final String appSign = '0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,'
                         '0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,'
                         '0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,'
                         '0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00';

  String version = '';

  @override
  void initState() {
    super.initState();

    // get SDK version
    ZegoLiveRoomPlugin.getSdkVersion().then((ver) {

      setState({
        version = ver;
      });

    });

    // init SDK
    ZegoLiveRoomPlugin.initSDK(appID, appSign);
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Zego Plugin example app'),
        ),
        body: Center(
          child: Text('Version: $version'),
        ),
      ),
    );
  }
}

Please refer to the API usage for more features.

7️⃣ API documentation #

ZegoLiveRoomPlugin API Reference

8️⃣ FAQ #

1. Solve the problem of compiling errors of ZegoLiveRoomApi-AudioIO and audio_in_output modules on iOS platform #

Open the iOS project file Runner. xcworkspace -> Build Settings, change Compile Sources As to Objective-C++, recompile.

2. iOS compiler error: ld: symbol(s) not found for architecture x86_64 #

Compilation with the simulator is not supported, please use real device debugging for best results.

3. iOS uses Platform View error: [VERBOSE-2:platform_view_layer.cc(28)] Trying to embed a platform view but the PaintContext does not support embedding #

Open the iOS project that requires Platform View and add the field io.flutter.embedded_views_preview to Info.plist with a value of YES.

4. fatal error: lipo: -extract armv7 specified but fat file: [...] does not contain that architecture #

Usually occurs when switching iOS devices, which can be resolved by deleting the "flutter-project-path/build/" and "flutter-project-path/ios/DerivedData/" directories.

5. Android building release crashes with NoClassDefFoundError when flutter is upgraded to 1.10 or above #

Flutter is enabled obfuscation by default in version 1.10 or above. Please add the following line in app/proguard-rules.pro to prevent the Zego SDK obfuscation.

-keep class com.zego.**{*;}

9️⃣ Contributing #

We welcome contributions, everyone is welcome to contribute code via pull requests, to help people asking for help, to add to our documentation, or to help out in any other way.

Change log #

1.2.12 #

  • Add MediaPlayer (only audio module)

1.2.11 #

  1. Update iOS native SDK to version 200424_175024_release-new-0-gb8ff47533_video_mediaplayer_bn3845_12

  2. Update Android native SDK to version 200424_175024_release-new-0-gb8ff47533_video_mediaplayer_bn3845_12

1.2.10 #

  • Add setCamZoomFactor, getCamMaxZoomFactor to adjust the camera zoom factor.

1.2.9 #

  1. Add sendBigRoomMessage, onRecvBigRoomMessage to send and receive big room messages.

  2. Add onUpdateOnlineCount callback to received online user number updates.

1.2.8 #

  1. Update iOS native SDK to version 200415_195052_release-new-0-g18e243156_video_mediaplayer_bn3792_12

  2. Update Android native SDK to version 200410_212545_release-new-0-g18e243156_video_mediaplayer_bn3760_12

1.2.7 #

  1. Add log for texture render.

  2. Optimize the code when calling updatePreviewRenderSize and updatePlayRenderSize

1.2.6 #

  1. Added setConfig for setting additional configuration information.

  2. Update iOS/Android native SDK to version 200316_163753_release-new-0-gb76c836cd_video_mediaplayer_bn3590_12

1.2.5 #

  1. Update ios/android native sdk to version 200309_200607_release-new-0-g54f488a0c_video_mediaplayer_bn3549_12

  2. Fix bug of external filter module on Android.

1.2.4 #

  • Add external video filter interface and corresponding sample code.

1.2.3 #

  • Add setSharpenFactor to set the sharpening factor for beauty.

1.2.2 #

  • Add sendRoomMessage, onRecvRoomMessage to send and receive room messages.

1.2.1 #

  • Update android native sdk.

1.2.0 #

  1. Add seekTo getTotalDuration getCurrentDuration in AudioPlayer.

  2. Add enableLoopback setLoopbackVolume to listen captured voice.

1.1.9 #

  • Update iOS/Android native sdk (2020.2.9 hotfix)

1.1.8 #

  • Update iOS/Android native sdk (2020.2.9)

1.1.7 #

  • Fix bug of init page in example.

1.1.6 #

  1. This new version is compatible with AndroidX.

  2. Fix the Android example crash in release mode because of the obfuscation.

1.1.5 #

  • Fix iOS: use platform view render failed.

1.1.4 #

  • Fix AudioPlayer bug.

1.1.3 #

  • Add Audio Precessing API: VirtualStereo, Reverb, VoiceChanger

1.1.2 #

  1. Fix iOS callback doesn’t work when call initSDK failed

  2. iOS native framework uses cocoapods dependency instead

1.1.1 #

  1. Add audio player module

  2. Update texture's API comment

1.0.12 #

  • Update iOS/Android native sdk (12.9)

1.0.11 #

  1. Add onInnerError

  2. Update iOS/Android native sdk

1.0.10 #

  1. Add relay CDN methods: setPublishConfig, addPublishTarget, deletePublishTarget, and callback: onRelayCDNStateUpdate

  2. Fix bug that xcode11 can't run in debug mode

  3. Update iOS/Android native sdk

1.0.9 #

  • Fix the problem that Android can't receive media sideinfo callback

1.0.8 #

  1. Add setVideoMirrorMode API

  2. Update iOS/Android native sdk

1.0.7 #

  1. Fix android texture render crash into background

  2. Fix android startPlayingStream bugs

  3. Update android native sdk

1.0.6 #

  1. Fix some bug and crash

  2. Add log system

1.0.5 #

  1. Add peer to peer delay/package lost rate.

  2. Add remote user's device state notification(on/off)

  3. Add remote user's first frame notification

  4. Update native sdk

  5. promote stability

1.0.4 #

  1. Add sound-level module

  2. Add error-code module

  3. Update native sdk

1.0.3 #

  • Add Platform View API

1.0.2 #

  1. Update native sdk

  2. Fix crash

  3. Refactor api structure

1.0.1 #

  • Add format interface

1.0.0 #

  • Initial release

example/lib/main.dart

import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:example/pages/init_sdk_page.dart';
import 'package:example/config/zego_config.dart';

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Zego Flutter Demo',
      theme: ThemeData(

        primarySwatch: Colors.blue,
      ),
      home: HomePage(title: '互动视频示例'),
    );
  }
}

class HomePage extends StatelessWidget {
  HomePage({Key key, this.title}) : super(key: key);

  final String title;

  @override
  Widget build(BuildContext context) {

    ZegoConfig config = new ZegoConfig();

    // TODO: implement build
    return Scaffold(
        appBar: AppBar(

          title: Text(title),
        ),
        body: SafeArea(
            child: Center(
              child: Column(
                mainAxisAlignment: MainAxisAlignment.center,
                children: <Widget>[
                  Text('基础功能'),
                  Padding(
                    padding: const EdgeInsets.only(bottom: 10.0),
                  ),
                  CupertinoButton(
                      color: Color(0xff0e88eb),
                      child: Text('推流'),
                      onPressed: () {
                        Navigator.of(context).push(MaterialPageRoute(builder: (BuildContext context) {
                          return InitPage(true);
                        }));
                      }
                  ),
                  Padding(
                    padding: const EdgeInsets.only(bottom: 10.0),
                  ),
                  CupertinoButton(
                      color: Color(0xff0e88eb),
                      child: Text('拉流'),
                      onPressed: () {
                        Navigator.of(context).push(MaterialPageRoute(builder: (BuildContext context) {
                          return InitPage(false);
                        }));
                      }
                  ),
                ],
              ),
            )
        )
    );
  }
}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  zegoliveroom_plugin: ^1.2.12

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter pub get

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:zegoliveroom_plugin/zegoliveroom_plugin.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
59
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
79
Learn more about scoring.

We analyzed this package on Jul 7, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.8.4
  • pana: 0.13.14
  • Flutter: 1.17.5

Analysis suggestions

Package does not support Flutter platform linux

Because:

  • package:zegoliveroom_plugin/zegoliveroom_plugin.dart that declares support for platforms: android, ios

Package does not support Flutter platform macos

Because:

  • package:zegoliveroom_plugin/zegoliveroom_plugin.dart that declares support for platforms: android, ios

Package does not support Flutter platform web

Because:

  • package:zegoliveroom_plugin/zegoliveroom_plugin.dart that declares support for platforms: android, ios

Package does not support Flutter platform windows

Because:

  • package:zegoliveroom_plugin/zegoliveroom_plugin.dart that declares support for platforms: android, ios

Package not compatible with SDK dart

Because:

  • zegoliveroom_plugin that is a package requiring null.

Health suggestions

Format lib/src/zego_api_defines.dart.

Run flutter format to format lib/src/zego_api_defines.dart.

Format lib/src/zego_api_error_code.dart.

Run flutter format to format lib/src/zego_api_error_code.dart.

Format lib/src/zego_audioplayer.dart.

Run flutter format to format lib/src/zego_audioplayer.dart.

Fix additional 8 files with analysis or formatting issues.

Additional issues in the following files:

  • lib/src/zego_liveroom.dart (Run flutter format to format lib/src/zego_liveroom.dart.)
  • lib/src/zego_liveroom_audio.dart (Run flutter format to format lib/src/zego_liveroom_audio.dart.)
  • lib/src/zego_liveroom_event_channel.dart (Run flutter format to format lib/src/zego_liveroom_event_channel.dart.)
  • lib/src/zego_liveroom_player.dart (Run flutter format to format lib/src/zego_liveroom_player.dart.)
  • lib/src/zego_liveroom_publisher.dart (Run flutter format to format lib/src/zego_liveroom_publisher.dart.)
  • lib/src/zego_media_side_info.dart (Run flutter format to format lib/src/zego_media_side_info.dart.)
  • lib/src/zego_mediaplayer.dart (Run flutter format to format lib/src/zego_mediaplayer.dart.)
  • lib/src/zego_sound_level.dart (Run flutter format to format lib/src/zego_sound_level.dart.)

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0 <3.0.0
flutter 0.0.0
Transitive dependencies
collection 1.14.12 1.14.13
meta 1.1.8 1.2.1
sky_engine 0.0.99
typed_data 1.1.6 1.2.0
vector_math 2.0.8