Home > Mobile >  How to create Video call function in flutter app
How to create Video call function in flutter app

Time:03-05

I want to create video call function in my app.Can you suggest some ideas for video call function in flutter app?

CodePudding user response:

I would comment this but I don't have enough rep to lol.

Does this link help? https://medium.flutterdevs.com/video-calling-in-flutter-7621ac5747dc

Or here's a video link if you prefer those https://www.youtube.com/watch?v=ULgX_Xt2NrY

Let me know if not xx

CodePudding user response:

import 'package:flutter/material.dart';
import 'package:agora_rtc_engine/rtc_engine.dart';
import 'package:permission_handler/permission_handler.dart';

import './video_call.dart';

class HomePage extends StatefulWidget {
  @override
  State<StatefulWidget> createState() => IndexState();
}

class IndexState extends State<HomePage> {
  final _channelController = TextEditingController();
  bool _validateError = false;

  ClientRole _role = ClientRole.Broadcaster;

  @override
  void dispose() {
    _channelController.dispose();
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        automaticallyImplyLeading: false,
        title: Text('Flutter Video Call Demo'),
        centerTitle: true,
      ),
      body: Center(
        child: Container(
          padding: const EdgeInsets.symmetric(horizontal: 20),
          height: 400,
          child: Column(
            children: <Widget>[
              Row(
                children: <Widget>[
                  Expanded(
                      child: TextField(
                    controller: _channelController,
                    decoration: InputDecoration(
                      errorText:
                          _validateError ? 'Channel name is mandatory' : null,
                      border: UnderlineInputBorder(
                        borderSide: BorderSide(width: 1),
                      ),
                      hintText: 'Channel name',
                    ),
                  ))
                ],
              ),
              Column(
                children: [
                  ListTile(
                    title: Text(ClientRole.Broadcaster.toString()),
                    leading: Radio(
                      value: ClientRole.Broadcaster,
                      groupValue: _role,
                      onChanged: (ClientRole value) {
                        setState(() {
                          _role = value;
                        });
                      },
                    ),
                  ),
                  ListTile(
                    title: Text(ClientRole.Audience.toString()),
                    leading: Radio(
                      value: ClientRole.Audience,
                      groupValue: _role,
                      onChanged: (ClientRole value) {
                        setState(() {
                          _role = value;
                        });
                      },
                    ),
                  )
                ],
              ),
              Padding(
                padding: const EdgeInsets.symmetric(vertical: 20),
                child: Row(
                  children: <Widget>[
                    Expanded(
                      child: RaisedButton(
                        onPressed: onJoin,
                        child: Text('Join'),
                        color: Colors.blueAccent,
                        textColor: Colors.white,
                      ),
                    )
                  ],
                ),
              )
            ],
          ),
        ),
      ),
    );
  }

  Future<void> onJoin() async {
    // update input validation
    setState(() {
      _channelController.text.isEmpty
          ? _validateError = true
          : _validateError = false;
    });
    if (_channelController.text.isNotEmpty) {
      await _handleCameraAndMic(Permission.camera);
      await _handleCameraAndMic(Permission.microphone);
      await Navigator.push(
        context,
        MaterialPageRoute(
          builder: (context) => VideoCall(
            channelName: _channelController.text,
            role: _role,
          ),
        ),
      );
    }
  }

  Future<void> _handleCameraAndMic(Permission permission) async {
    final status = await permission.request();
    print(status);
  }
}

CodePudding user response:

Use this plugin

Jitsi_meet

And to join a meeting use

_joinMeeting() async {
try {
  FeatureFlag featureFlag = FeatureFlag();
  featureFlag.welcomePageEnabled = false;
  featureFlag.resolution = FeatureFlagVideoResolution.MD_RESOLUTION; // Limit video resolution to 360p
  
  var options = JitsiMeetingOptions()
    ..room = "myroom" // Required, spaces will be trimmed
    ..serverURL = "https://someHost.com"
    ..subject = "Meeting with Gunschu"
    ..userDisplayName = "My Name"
    ..userEmail = "[email protected]"
    ..userAvatarURL = "https://someimageurl.com/image.jpg" // or .png
    ..audioOnly = true
    ..audioMuted = true
    ..videoMuted = true
    ..featureFlag = featureFlag;

  await JitsiMeet.joinMeeting(options);
} catch (error) {
  debugPrint("error: $error");
}
}

The plug-in is open source and works great on ios and Android.

CodePudding user response:

Use the Meet hour plugin. As per plugin description, it provides a free video conference solution with End to End Encrypted and many other features such as lobby mode, Donor box & Click&Pledge Connect for fundraising, Video call recording, Youtube Live Stream, etc.

  • Related