Skip to main content

zego_express_engine 3.23.0-private.592 copy "zego_express_engine: ^3.23.0-private.592" to clipboard
zego_express_engine: ^3.23.0-private.592 copied to clipboard

ZegoExpressEngine Flutter SDK is a flutter plugin wrapper based on ZEGO Express RTC SDK (Native & Web), providing live video and real-time audio/video services.

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:zego_express_engine/zego_express_engine.dart';
import 'package:zego_express_engine_example/home/home_page.dart';
import 'package:zego_express_engine_example/topics/autotest_reporter.dart';
import 'package:zego_express_engine_example/topics/mixer/mixer_autotest.dart';
import 'package:zego_express_engine_example/topics/mixer/mixer_render_page.dart';
import 'package:zego_express_engine_example/topics/utility/utility_autotest.dart';
import 'package:zego_express_engine_example/utils/zego_config.dart';

// This is a simple publish & play stream demo,
// shows the basic function of the SDK.

// You can refer to this example topic demo for more use cases.
// https://github.com/zegoim/zego-express-example-topics-flutter

/// Device-side automation switch.
///
///   flutter build hap --debug \
///     --dart-define=MIXER_AUTOTEST=true \
///     --dart-define=ZEGO_APP_ID=<appID> \
///     --dart-define=ZEGO_APP_SIGN=<appSign>
///
/// When enabled, the app boots, creates the engine with the injected
/// credentials, runs the mixer / media player / network time cases, and prints
/// `ZMX_TEST|...` markers to hilog. See tool/run_mixer_autotest.sh.
const bool kAutoTest = bool.fromEnvironment('AUTOTEST') ||
    bool.fromEnvironment('MIXER_AUTOTEST');

/// Opens the mixer render page as home: --dart-define=MIXER_RENDER=true
const bool kMixerRender = bool.fromEnvironment('MIXER_RENDER');

const int kAutoTestAppID = int.fromEnvironment('ZEGO_APP_ID');
const String kAutoTestAppSign = String.fromEnvironment('ZEGO_APP_SIGN');
const String kAutoTestMainStream = String.fromEnvironment(
    'MIXER_INPUT_STREAM',
    defaultValue: 'mixer-autotest-in-1');
const String kAutoTestAuxStream =
    String.fromEnvironment('MIXER_AUX_STREAM', defaultValue: 'mixer-autotest-in-2');
const String kAutoTestRoomID =
    String.fromEnvironment('MIXER_ROOM_ID', defaultValue: 'mixer-autotest-room');
const bool kAutoTestPublish =
    bool.fromEnvironment('MIXER_PUBLISH', defaultValue: true);
const String kAutoTestOutputTarget = String.fromEnvironment(
    'MIXER_OUTPUT_TARGET',
    defaultValue: 'mixer-autotest-out');

void main() {
  WidgetsFlutterBinding.ensureInitialized();

  // Allow credentials injection for the automated / render modes
  if (kAutoTestAppID > 0) {
    ZegoConfig.instance.appID = kAutoTestAppID;
    ZegoConfig.instance.appSign = kAutoTestAppSign;
    ZegoConfig.instance.userID = 'ohos_autotest';
  }

  runApp(MyApp());

  if (kAutoTest) {
    _runAutoTest();
  }
}

Future<void> _runAutoTest() async {
  print('ZMX_TEST|START|prepare');

  if (kAutoTestAppID <= 0) {
    print('ZMX_TEST|FAIL|prepare|missing --dart-define=ZEGO_APP_ID');
    print('ZMX_TEST|DONE|passed=0|failed=1');
    return;
  }

  ZegoConfig.instance.appID = kAutoTestAppID;
  ZegoConfig.instance.appSign = kAutoTestAppSign;
  ZegoConfig.instance.userID = 'ohos_autotest';

  ZegoEngineProfile profile = ZegoEngineProfile(
      ZegoConfig.instance.appID, ZegoConfig.instance.scenario,
      appSign: ZegoConfig.instance.appSign);
  ZegoExpressEngine.createEngineWithProfile(profile);
  print('ZMX_TEST|PASS|prepare|engineCreated,appID=${ZegoConfig.instance.appID}');

  // Give the native engine time to initialize before calling the APIs
  await Future.delayed(const Duration(seconds: 2));

  AutoTestReporter.reset();

  // Non-mixer APIs first (they only need the engine)
  await UtilityAutoTest.run();

  // Mixer task suite (logs in and publishes its own input streams)
  await MixerAutoTest.run(
      roomID: kAutoTestRoomID,
      inputMainStreamID: kAutoTestMainStream,
      inputAuxStreamID: kAutoTestAuxStream,
      outputTarget: kAutoTestOutputTarget,
      publishInputs: kAutoTestPublish);

  AutoTestReporter.done();

  ZegoExpressEngine.destroyEngine();
  print('ZMX_TEST|FINISHED');
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'ZegoExpressExample',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: kMixerRender ? MixerRenderPage() : HomePage(),
    );
  }
}
59
likes
0
points
12.5k
downloads

Publisher

verified publisherzego.im

Weekly Downloads

ZegoExpressEngine Flutter SDK is a flutter plugin wrapper based on ZEGO Express RTC SDK (Native & Web), providing live video and real-time audio/video services.

Homepage

License

unknown (license)

Dependencies

flutter, flutter_web_plugins, js

More

Packages that depend on zego_express_engine

Packages that implement zego_express_engine