youme_rtc_engine 0.0.1 youme_rtc_engine: ^0.0.1 copied to clipboard
Flutter plugin of Youme RTC SDK, allow you to simply integrate Youme Video Calling or Live Video Chat to your app with just a few lines of code.
import 'package:flutter/material.dart';
import 'dart:async';
import 'package:flutter/services.dart';
import 'package:youme_rtc_engine/youme_rtc_engine.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatefulWidget {
@override
_MyAppState createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
int _initCode = -1;
int joinChannelState = 0;
@override
void initState() {
super.initState();
initPlatformState();
// YoumeRtcEngine.initSDK();
}
// Platform messages are asynchronous, so we initialize in an async method.
Future<void> initPlatformState() async {
int initCode = 0;
// Platform messages may fail, so we use a try/catch PlatformException.
try {
var appKey = "YOUME5BE427937AF216E88E0F84C0EF148BD29B691556";
var appSecret =
"y1sepDnrmgatu/G8rx1nIKglCclvuA5tAvC0vXwlfZKOvPZfaUYOTkfAdUUtbziW8Z4HrsgpJtmV/RqhacllbXD3abvuXIBlrknqP+Bith9OHazsC1X96b3Inii6J7Und0/KaGf3xEzWx/t1E1SbdrbmBJ01D1mwn50O/9V0820BAAE=";
await YoumeRtcEngine.init(
appKey,
appSecret,
0,
"",
);
} on PlatformException {
initCode = -2;
}
// If the widget was removed from the tree while the asynchronous platform
// message was in flight, we want to discard the reply rather than calling
// setState to update our non-existent appearance.
if (!mounted) return;
setState(() {
_initCode = initCode;
});
}
Future<void> joinChannel() async {
int code;
try {
var channelId = "aaaaa";
var userId = "userId-111";
var userRole = 1;
code = await YoumeRtcEngine.joinChannel(channelId, userId, userRole);
} catch (e) {
code = -1;
}
setState(() {
joinChannelState = code;
});
}
static TextStyle textStyle = TextStyle(fontSize: 18, color: Colors.blue);
Widget mainBody() {
return Column(children: <Widget>[
Row(children: <Widget>[
new Center(child: Text("init state: $_initCode"))
]),
Row(children: <Widget>[
OutlineButton(
child: Text('Join Channel: aaa, state: $joinChannelState',
style: textStyle),
onPressed: joinChannel,
),
]),
Row(children: <Widget>[]),
Row(children: <Widget>[]),
Row(children: <Widget>[]),
]);
}
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: const Text('YouMe RTC'),
),
body: Center(
child: mainBody(),
),
),
);
}
}