jitsi_meet 0.1.5 jitsi_meet: ^0.1.5 copied to clipboard
Jitsi Meet Plugin
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:jitsi_meet/jitsi_meet.dart';
import 'package:jitsi_meet/jitsi_meeting_listener.dart';
void main() => runApp(MyApp());
class MyApp extends StatefulWidget {
@override
_MyAppState createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
final serverText = TextEditingController();
final roomText = TextEditingController(text: "plugintestroom");
final subjectText = TextEditingController(text: "My Plugin Test Meeting");
final nameText = TextEditingController(text: "Plugin Test User");
final emailText = TextEditingController(text: "fake@email.com");
var isAudioOnly = true;
var isAudioMuted = true;
var isVideoMuted = true;
@override
void initState() {
super.initState();
JitsiMeet.addListener(JitsiMeetingListener(
onConferenceWillJoin: _onConferenceWillJoin,
onConferenceJoined: _onConferenceJoined,
onConferenceTerminated: _onConferenceTerminated,
onError: _onError));
}
@override
void dispose() {
super.dispose();
JitsiMeet.removeAllListeners();
}
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: const Text('Plugin example app'),
),
body: Container(
padding: const EdgeInsets.symmetric(
horizontal: 16.0,
),
child: SingleChildScrollView(
child: Column(
children: <Widget>[
SizedBox(
height: 24.0,
),
TextField(
controller: serverText,
decoration: InputDecoration(
border: OutlineInputBorder(),
labelText: "Server URL",
hintText: "Hint: Leave empty for meet.jitsi.si"),
),
SizedBox(
height: 16.0,
),
TextField(
controller: roomText,
decoration: InputDecoration(
border: OutlineInputBorder(),
labelText: "Room",
),
),
SizedBox(
height: 16.0,
),
TextField(
controller: subjectText,
decoration: InputDecoration(
border: OutlineInputBorder(),
labelText: "Subject",
),
),
SizedBox(
height: 16.0,
),
TextField(
controller: nameText,
decoration: InputDecoration(
border: OutlineInputBorder(),
labelText: "Display Name",
),
),
SizedBox(
height: 16.0,
),
TextField(
controller: emailText,
decoration: InputDecoration(
border: OutlineInputBorder(),
labelText: "Email",
),
),
SizedBox(
height: 16.0,
),
CheckboxListTile(
title: Text("Audio Only"),
value: isAudioOnly,
onChanged: _onAudioOnlyChanged,
),
SizedBox(
height: 16.0,
),
CheckboxListTile(
title: Text("Audio Muted"),
value: isAudioMuted,
onChanged: _onAudioMutedChanged,
),
SizedBox(
height: 16.0,
),
CheckboxListTile(
title: Text("Video Muted"),
value: isVideoMuted,
onChanged: _onVideoMutedChanged,
),
Divider(
height: 48.0,
thickness: 2.0,
),
SizedBox(
height: 64.0,
width: double.maxFinite,
child: RaisedButton(
onPressed: () {
_joinMeeting();
},
child: Text(
"Join Meeting",
style: TextStyle(color: Colors.white),
),
color: Colors.blue,
),
),
SizedBox(
height: 48.0,
),
],
),
),
),
),
);
}
_onAudioOnlyChanged(bool value) {
setState(() {
isAudioOnly = value;
});
}
_onAudioMutedChanged(bool value) {
setState(() {
isAudioMuted = value;
});
}
_onVideoMutedChanged(bool value) {
setState(() {
isVideoMuted = value;
});
}
_joinMeeting() async {
String serverUrl =
serverText.text?.trim()?.isEmpty ?? "" ? null : serverText.text;
try {
var options = JitsiMeetingOptions()
..room = roomText.text
..serverURL = serverUrl
..subject = subjectText.text
..userDisplayName = nameText.text
..userEmail = emailText.text
..audioOnly = isAudioOnly
..audioMuted = isAudioMuted
..videoMuted = isVideoMuted;
debugPrint("JitsiMeetingOptions: $options");
await JitsiMeet.joinMeeting(options);
} catch (error) {
debugPrint("error: $error");
}
}
void _onConferenceWillJoin() {
debugPrint("_onConferenceWillJoin broadcasted");
}
void _onConferenceJoined() {
debugPrint("_onConferenceJoined broadcasted");
}
void _onConferenceTerminated() {
debugPrint("_onConferenceTerminated broadcasted");
}
_onError(error) {
debugPrint("_onError broadcasted");
}
}