Skip to content

Commit

Permalink
fix: plugin not working on web release mode #63
Browse files Browse the repository at this point in the history
  • Loading branch information
LichKing-2234 committed Jul 1, 2021
1 parent 196627e commit 4dcc71a
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 33 deletions.
29 changes: 13 additions & 16 deletions example/lib/examples/advanced/screen_sharing.dart
Original file line number Diff line number Diff line change
Expand Up @@ -36,23 +36,20 @@ class _State extends State<ScreenSharing> {
}

_initEngine() {
RtcEngine.createWithContext(RtcEngineContext(config.appId)).then((value) {
RtcEngine.createWithContext(RtcEngineContext(config.appId))
.then((value) async {
_engine = value;
_addListeners();
await _engine.enableVideo();
if (kIsWeb) {
await _engine.startScreenCapture(0);
} else {
await _engine.startPreview();
}
await _engine.setChannelProfile(ChannelProfile.LiveBroadcasting);
await _engine.setClientRole(ClientRole.Broadcaster);
setState(() {
_engine = value;
_addListeners();
() async {
await _engine.enableVideo();
if (kIsWeb) {
await _engine.startScreenCapture(0);
} else {
await _engine.startPreview();
}
await _engine.setChannelProfile(ChannelProfile.LiveBroadcasting);
await _engine.setClientRole(ClientRole.Broadcaster);
setState(() {
startPreview = true;
});
}();
startPreview = true;
});
});
}
Expand Down
33 changes: 16 additions & 17 deletions example/lib/examples/basic/join_channel_video.dart
Original file line number Diff line number Diff line change
Expand Up @@ -39,19 +39,16 @@ class _State extends State<JoinChannelVideo> {
}

_initEngine() {
RtcEngine.createWithContext(RtcEngineContext(config.appId)).then((value) {
RtcEngine.createWithContext(RtcEngineContext(config.appId))
.then((value) async {
_engine = value;
_addListeners();
await _engine.enableVideo();
await _engine.startPreview();
await _engine.setChannelProfile(ChannelProfile.LiveBroadcasting);
await _engine.setClientRole(ClientRole.Broadcaster);
setState(() {
_engine = value;
_addListeners();
() async {
await _engine.enableVideo();
await _engine.startPreview();
await _engine.setChannelProfile(ChannelProfile.LiveBroadcasting);
await _engine.setClientRole(ClientRole.Broadcaster);
setState(() {
startPreview = true;
});
}();
startPreview = true;
});
});
}
Expand All @@ -78,11 +75,13 @@ class _State extends State<JoinChannelVideo> {
},
remoteVideoStateChanged: (uid, state, reason, elapsed) {
log('remoteVideoStateChanged ${uid} ${state} ${reason} ${elapsed}');
// if (state == VideoRemoteState.Decoding) {
// setState(() {
// remoteUid.add(uid);
// });
// }
if (kIsWeb) {
if (state == VideoRemoteState.Decoding) {
setState(() {
remoteUid.add(uid);
});
}
}
},
userOffline: (uid, reason) {
log('userOffline ${uid} ${reason}');
Expand Down
2 changes: 2 additions & 0 deletions lib/agora_rtc_engine_web.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ import 'package:js/js_util.dart';

@JS('IrisRtcEngine')
class _IrisRtcEngine {
external _IrisRtcEngine();

external _IrisRtcDeviceManager get deviceManager;

external Future<dynamic> callApi(int apiType, String params, [Object? extra]);
Expand Down

0 comments on commit 4dcc71a

Please sign in to comment.