Create room without connecting (#49)

* initial commit

* fix example compile

* format

* clean up

* fix check

* missing import
This commit is contained in:
Hiroshi Horie
2021-12-07 17:02:58 +07:00
committed by GitHub
parent c4e56af4c0
commit 0f5a758cd4
5 changed files with 73 additions and 87 deletions
+15 -10
View File
@@ -68,13 +68,13 @@ class _RoomPageState extends State<RoomPage> {
if (result != true) return;
// video will fail when running in ios simulator
try {
await widget.room.localParticipant.setCameraEnabled(true);
await widget.room.localParticipant?.setCameraEnabled(true);
} catch (error) {
print('could not publish video: $error');
await context.showErrorDialog(error);
}
try {
await widget.room.localParticipant.setMicrophoneEnabled(true);
await widget.room.localParticipant?.setMicrophoneEnabled(true);
} catch (error) {
print('could not publish audio: $error');
await context.showErrorDialog(error);
@@ -117,10 +117,13 @@ class _RoomPageState extends State<RoomPage> {
b.joinedAt.millisecondsSinceEpoch;
});
if (participants.length > 1) {
participants.insert(1, widget.room.localParticipant);
} else {
participants.add(widget.room.localParticipant);
final localParticipant = widget.room.localParticipant;
if (localParticipant != null) {
if (participants.length > 1) {
participants.insert(1, localParticipant);
} else {
participants.add(localParticipant);
}
}
setState(() {
this.participants = participants;
@@ -147,10 +150,12 @@ class _RoomPageState extends State<RoomPage> {
),
),
),
SafeArea(
top: false,
child: ControlsWidget(widget.room),
),
if (widget.room.localParticipant != null)
SafeArea(
top: false,
child:
ControlsWidget(widget.room, widget.room.localParticipant!),
),
],
),
);