Coder Social home page Coder Social logo

davidalphafox / flutter_trtc_plugin Goto Github PK

View Code? Open in Web Editor NEW

This project forked from scofield-hello/flutter_trtc_plugin

0.0 1.0 0.0 13.8 MB

腾讯云实时音视频 Flutter插件

License: Other

Java 30.00% Objective-C 68.08% Dart 1.36% Ruby 0.55%

flutter_trtc_plugin's Introduction

flutter_trtc_plugin

腾讯视频电话/直播SDK Flutter插件.

Getting Started

腾讯云实时音视频

1.在pubspec.yaml中添加插件依赖项

  dependencies:
    flutter_trtc_plugin:
      git: git://github.com/scofield-hello/flutter_trtc_plugin.git

2.创建/加入房间

import 'package:flutter/services.dart';
import 'package:flutter_trtc_plugin/flutter_trtc_plugin.dart';

final pluginReference = FlutterTrtcPlugin();

Future<void> join() async {
    // Platform messages may fail, so we use a try/catch PlatformException.
    try {
      await pluginReference.joinRoom(
          devMode: false,//是否开发模式
          roomId: 1000001,//房间号
          appId: 1,//APP ID
          userId: "用户ID",
          userSig: '签名数据从后台获取');
    } on PlatformException {
      print("------------出错啦.");
    }
  }

3.事件监听

StreamSubscription<Map<String, dynamic>> _onErrorSubscription;
StreamSubscription<int> _onEnterSubscription;
StreamSubscription<dynamic> ...;

@override
void initState() {
  _onErrorSubscription = pluginReference.onError.listen((Map<String, dynamic> error) async {
        print("------------------------FLUTTER-TRTC-PLUGIN: onError:$error");
  });
  _onEnterSubscription = pluginReference.onEnterRoom.listen((int delay) async {
    print("------------------------FLUTTER-TRTC-PLUGIN: onEnterRoom:$delay");
  });
  pluginReference.onExitRoom.listen((int reason) async {
    print("------------------------FLUTTER-TRTC-PLUGIN: onExitRoom:$reason");
  });
  pluginReference.onUserEnter.listen((String userId) async {
    print("------------------------FLUTTER-TRTC-PLUGIN: onUserEnter($userId)");
  });
  pluginReference.onUserExit.listen((Map<String, dynamic> result) async {
    print("------------------------FLUTTER-TRTC-PLUGIN: onUserExit($result)");
  });
}

  @override
  void dispose() {
    super.dispose();
    _onEnterSubscription?.cancel();
    _onErrorSubscription?.cancel();
    ...?.cancel();
  }

...还有更多事件请查看 flutter_trtc_plugin.dart

Stream<Map<String, dynamic>> get onError => _onError.stream;
  Stream<Map<String, dynamic>> get onWarning => _onWarning.stream;
  Stream<int> get onEnterRoom => _onEnterRoom.stream;
  Stream<int> get onExitRoom => _onExitRoom.stream;
  Stream<Map<String, dynamic>> get onSwitchRole => _onSwitchRole.stream;
  Stream<Map<String, dynamic>> get onConnectOtherRoom => _onConnectOtherRoom.stream;
  Stream<Map<String, dynamic>> get onDisConnectOtherRoom => _onDisConnectOtherRoom.stream;
  Stream<String> get onUserEnter => _onUserEnter.stream;
  Stream<Map<String, dynamic>> get onUserExit => _onUserExit.stream;
  Stream<Map<String, dynamic>> get onUserVideoAvailable => _onUserVideoAvailable.stream;
  Stream<Map<String, dynamic>> get onUserSubStreamAvailable => _onUserSubStreamAvailable.stream;
  Stream<Map<String, dynamic>> get onUserAudioAvailable => _onUserAudioAvailable.stream;
  Stream<Map<String, dynamic>> get onFirstVideoFrame => _onFirstVideoFrame.stream;
  Stream<String> get onFirstAudioFrame => _onFirstAudioFrame.stream;
  Stream<int> get onSendFirstLocalVideoFrame => _onSendFirstLocalVideoFrame.stream;
  Stream<Null> get onSendFirstLocalAudioFrame => _onSendFirstLocalAudioFrame.stream;
  Stream<Map<String, dynamic>> get onNetworkQuality => _onNetworkQuality.stream;
  Stream<Map<String, dynamic>> get onStatistics => _onStatistics.stream;
  Stream<Null> get onConnectionLost => _onConnectionLost.stream;
  Stream<Null> get onTryToReconnect => _onTryToReconnect.stream;
  Stream<Null> get onConnectionRecovery => _onConnectionRecovery.stream;
  Stream<Map<String, dynamic>> get onSpeedTest => _onSpeedTest.stream;
  Stream<Null> get onCameraDidReady => _onCameraDidReady.stream;
  Stream<Null> get onMicDidReady => _onMicDidReady.stream;
  Stream<Map<String, dynamic>> get onAudioRouteChanged => _onAudioRouteChanged.stream;
  Stream<Map<String, dynamic>> get onUserVoiceVolume => _onUserVoiceVolume.stream;
  Stream<Map<String, dynamic>> get onRecvCustomCmdMsg => _onRecvCustomCmdMsg.stream;
  Stream<Map<String, dynamic>> get onMissCustomCmdMsg => _onMissCustomCmdMsg.stream;
  Stream<Map<String, dynamic>> get onRecvSEIMsg => _onRecvSEIMsg.stream;
  Stream<Map<String, dynamic>> get onStartPublishCDNStream => _onStartPublishCDNStream.stream;
  Stream<Map<String, dynamic>> get onStopPublishCDNStream => _onStopPublishCDNStream.stream;
  Stream<Map<String, dynamic>> get onSetMixTranscodingConfig => _onSetMixTranscodingConfig.stream;
  Stream<Map<String, dynamic>> get onAudioEffectFinished => _onAudioEffectFinished.stream;

This project is a starting point for a Flutter plug-in package, a specialized package that includes platform-specific implementation code for Android and/or iOS.

For help getting started with Flutter, view our online documentation, which offers tutorials, samples, guidance on mobile development, and a full API reference.

flutter_trtc_plugin's People

Contributors

scofield-hello avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.