vdotok_stream 0.0.23 copy "vdotok_stream: ^0.0.23" to clipboard
vdotok_stream: ^0.0.23 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 '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(),
            hintColor: 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: [
           

            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),
            ),
            TextButton(
              onPressed: () {
                signalingClient?.getNumber();
              },
              child: Text("Create peerConnection"),
            ),
            TextButton(
              onPressed: () {
                // signalingClient.creteOffermannual();
              },
              child: Text("createOffer"),
            ),
            TextButton(
              onPressed: () {
                signalingClient?.getMedia();
              },
              child: Text("getUserMedia"),
            ),
            TextButton(
              onPressed: () {
                signalingClient?.getDisplay();
              },
              child: Text("getUserDisplayMedia"),
            ),
            TextButton(
              onPressed: () {
             
              },
              child: Text("connect"),
            ),
            TextButton(
              onPressed: () {
                signalingClient?.registerViewerApp(
                    "197fd41bb378f06a032f4372212995ba",
                    "4212a87edf17e3c7ac97932f8eb6229a",
                    "115G1WZI");
              },
              child: Text("Register"),
            )
          ],
        ),
      ),
    );
  }
}
2
likes
0
pub points
0%
popularity

Publisher

verified publishervdotok.com

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.

License

unknown (license)

Dependencies

crypto, dart_ipify, device_info_plus, flutter, flutter_device_type, flutter_web_plugins, http, media_projection_creator, path_provider, permission_handler, replay_kit_launcher, simple_connection_checker, web_socket_channel

More

Packages that depend on vdotok_stream