vdotok_stream 0.0.19 vdotok_stream: ^0.0.19 copied to clipboard
By using this package you can connect with vdotok and use vdotok services. you can make one 2 one, many 2 many, Group calls , broadcast etc.
example/lib/main.dart
// import 'package:flutter/material.dart';
// import 'dart:async';
// import 'package:flutter/services.dart';
// import 'package:vdotok_stream/vdotok_stream.dart';
// void main() {
// runApp(const MyApp());
// }
// class MyApp extends StatefulWidget {
// const MyApp({Key? key}) : super(key: key);
// @override
// State<MyApp> createState() => _MyAppState();
// }
// class _MyAppState extends State<MyApp> {
// String _platformVersion = 'Unknown';
// @override
// void initState() {
// super.initState();
// initPlatformState();
// }
// // Platform messages are asynchronous, so we initialize in an async method.
// Future<void> initPlatformState() async {
// String platformVersion;
// // Platform messages may fail, so we use a try/catch PlatformException.
// // We also handle the message potentially returning null.
// try {
// platformVersion =
// await VdotokStream.platformVersion ?? 'Unknown platform version';
// } on PlatformException {
// platformVersion = 'Failed to get platform version.';
// }
// // 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(() {
// _platformVersion = platformVersion;
// });
// }
// @override
// Widget build(BuildContext context) {
// return MaterialApp(
// home: Scaffold(
// appBar: AppBar(
// title: const Text('Plugin example app'),
// ),
// body: Center(
// child: Text('Running on: $_platformVersion\n'),
// ),
// ),
// );
// }
// }
import 'dart:io';
import 'package:flutter/material.dart';
import 'package:vdotok_stream/vdotok_stream.dart';
import 'package:vdotok_stream_example/constants.dart';
class MyHttpOverrides extends HttpOverrides {
@override
HttpClient createHttpClient(SecurityContext? context) {
return super.createHttpClient(context)
..badCertificateCallback =
(X509Certificate cert, String host, int port) => true;
}
}
void main() {
HttpOverrides.global = MyHttpOverrides();
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
title: 'Vdotok Video',
theme: ThemeData(
colorScheme: ColorScheme.fromSwatch(
primarySwatch: Colors.grey,
).copyWith(),
accentColor: primaryColor,
primaryColor: primaryColor,
scaffoldBackgroundColor: Colors.white,
textTheme: TextTheme(
bodyText1: TextStyle(color: secondaryColor),
bodyText2: TextStyle(color: secondaryColor), //Text
)),
// onGenerateRoute: Routers.generateRoute,
home: Test());
}
}
class Test extends StatefulWidget {
@override
_TestState createState() => _TestState();
}
class _TestState extends State<Test> {
SignalingClient? signalingClient;
MediaStream? _localStream;
RTCVideoRenderer _localRenderer = new RTCVideoRenderer();
RTCVideoRenderer _screenShareRenderer = new RTCVideoRenderer();
late TextEditingController _controller;
late TextEditingController _controllerSecondSession;
@override
void initState() {
// TODO: implement initState
// initRenderers();
_controller = TextEditingController();
_controllerSecondSession = TextEditingController();
signalingClient = SignalingClient.instance;
// signalingClient.methodInvoke();
super.initState();
initRenderers();
signalingClient?.onLocalStream = (stream) {
print("this is local stream ${stream}");
if (_localRenderer.srcObject == null) {
setState(() {
_localRenderer.srcObject = stream;
});
} else {
setState(() {
_screenShareRenderer.srcObject = stream;
});
}
};
signalingClient?.onRemoteStream = (stream, d) {
print("this is local stream ${stream}");
if (_localRenderer.srcObject == null) {
setState(() {
_localRenderer.srcObject = stream;
});
} else {
setState(() {
_screenShareRenderer.srcObject = stream;
});
}
};
// signalingClient.getPermissions();
}
Future<void> initRenderers() async {
// if (type == "screen") {
await _screenShareRenderer.initialize();
// } else {
await _localRenderer.initialize();
// }
}
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
// Center(
// child: TextField(
// controller: _controller,
// ),
// ),
// Center(
// child: TextField(
// controller: _controllerSecondSession,
// ),
// ),
// RaisedButton(
// onPressed: () {
// signalingClient?.connectViewerApp(
// [_controller.text, _controllerSecondSession.text]);
// },
// child: Text("Join Session"),
// ),
// RaisedButton(
// onPressed: () {
// signalingClient?.switchSpeaker(true);
// },
// child: Text("toogleSpeaker"),
// ),
Container(
width: 200,
height: 200,
child: _localRenderer.srcObject == null
? Text("camera")
: RTCVideoView(_localRenderer, mirror: false),
),
Container(
width: 200,
height: 200,
child: _screenShareRenderer.srcObject == null
? Text("screen")
: RTCVideoView(_screenShareRenderer, mirror: false),
),
RaisedButton(
onPressed: () {
signalingClient?.getNumber();
},
child: Text("Create peerConnection"),
),
RaisedButton(
onPressed: () {
// signalingClient.creteOffermannual();
},
child: Text("createOffer"),
),
RaisedButton(
onPressed: () {
signalingClient?.getMedia();
},
child: Text("getUserMedia"),
),
RaisedButton(
onPressed: () {
signalingClient?.getDisplay();
},
child: Text("getUserDisplayMedia"),
),
RaisedButton(
onPressed: () {
signalingClient?.connect(
"115G1WZI", "wss://q-signalling.vdotok.dev:8443/call");
},
child: Text("connect"),
),
RaisedButton(
onPressed: () {
signalingClient?.registerViewerApp(
"197fd41bb378f06a032f4372212995ba",
"4212a87edf17e3c7ac97932f8eb6229a",
"115G1WZI");
},
child: Text("Register"),
)
],
),
),
);
}
}