You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
68 lines
1.5 KiB
Dart
68 lines
1.5 KiB
Dart
import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter_webrtc/flutter_webrtc.dart';
|
|
|
|
class CallPage extends StatefulWidget {
|
|
@override
|
|
_CallPageState createState() => _CallPageState();
|
|
}
|
|
|
|
class _CallPageState extends State<CallPage> {
|
|
final _localRenderer = new RTCVideoRenderer();
|
|
|
|
@override
|
|
void initState() {
|
|
initializeRenderers();
|
|
_getUserMedia();
|
|
super.initState();
|
|
}
|
|
|
|
@override
|
|
void dispose() {
|
|
_localRenderer.dispose();
|
|
super.dispose();
|
|
}
|
|
|
|
void _getUserMedia() async {
|
|
final Map<String, dynamic> constraints = {
|
|
'audio': 'false',
|
|
'video': {'facingMode': 'user'},
|
|
};
|
|
|
|
MediaStream stream = await navigator.mediaDevices.getUserMedia(constraints);
|
|
setState(() {
|
|
_localRenderer.srcObject = stream;
|
|
});
|
|
}
|
|
|
|
void initializeRenderers() async {
|
|
_localRenderer.initialize();
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return AppScaffold(
|
|
isShowAppBar: true,
|
|
showNewAppBar: true,
|
|
showNewAppBarTitle: true,
|
|
isShowDecPage: false,
|
|
appBarTitle: "WebRTC Calling",
|
|
body: Container(
|
|
child: Stack(
|
|
children: [
|
|
Positioned(
|
|
top: 0.0,
|
|
left: 0.0,
|
|
right: 0.0,
|
|
bottom: 0.0,
|
|
child: Container(
|
|
child: new RTCVideoView(_localRenderer),
|
|
),
|
|
)
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|