From 5ce12dae85f8a3a35501c065f83f019c00173457 Mon Sep 17 00:00:00 2001 From: Hiroshi Horie <548776+hiroshihorie@users.noreply.github.com> Date: Tue, 7 Dec 2021 02:04:08 +0700 Subject: [PATCH] use setScreenShareEnabled for example --- example/lib/widgets/controls.dart | 60 ++++++++++++++++--------------- 1 file changed, 31 insertions(+), 29 deletions(-) diff --git a/example/lib/widgets/controls.dart b/example/lib/widgets/controls.dart index e04cd0a..9a2cf38 100644 --- a/example/lib/widgets/controls.dart +++ b/example/lib/widgets/controls.dart @@ -85,42 +85,44 @@ class _ControlsWidgetState extends State { } void _enableScreenShare() async { - final lp = widget.room.localParticipant; + await participant.setScreenShareEnabled(true); + // final lp = widget.room.localParticipant; - for (final track in lp.videoTracks) { - await lp.unpublishTrack(track.sid); - } + // for (final track in lp.videoTracks) { + // await lp.unpublishTrack(track.sid); + // } - try { - // Required for android screenshare. - const androidConfig = FlutterBackgroundAndroidConfig( - notificationTitle: 'Screen Sharing', - notificationText: 'LiveKit Example is sharing the screen.', - notificationImportance: AndroidNotificationImportance.Default, - notificationIcon: - AndroidResource(name: 'livekit_ic_launcher', defType: 'mipmap'), - ); - await FlutterBackground.initialize(androidConfig: androidConfig); - await FlutterBackground.enableBackgroundExecution(); + // try { + // // Required for android screenshare. + // const androidConfig = FlutterBackgroundAndroidConfig( + // notificationTitle: 'Screen Sharing', + // notificationText: 'LiveKit Example is sharing the screen.', + // notificationImportance: AndroidNotificationImportance.Default, + // notificationIcon: + // AndroidResource(name: 'livekit_ic_launcher', defType: 'mipmap'), + // ); + // await FlutterBackground.initialize(androidConfig: androidConfig); + // await FlutterBackground.enableBackgroundExecution(); - final screenShareTrack = await LocalVideoTrack.createScreenShareTrack(); - await widget.room.localParticipant.publishVideoTrack( - screenShareTrack, - ); - } catch (e) { - print('could not publish video: $e'); - } + // final screenShareTrack = await LocalVideoTrack.createScreenShareTrack(); + // await widget.room.localParticipant.publishVideoTrack( + // screenShareTrack, + // ); + // } catch (e) { + // print('could not publish video: $e'); + // } } void _disableScreenShare() async { - final lp = widget.room.localParticipant; + await participant.setScreenShareEnabled(false); + // final lp = widget.room.localParticipant; - try { - await lp.setScreenShareEnabled(false); - await FlutterBackground.disableBackgroundExecution(); - } catch (e) { - print('error disabling screen share: $e'); - } + // try { + // await lp.setScreenShareEnabled(false); + // await FlutterBackground.disableBackgroundExecution(); + // } catch (e) { + // print('error disabling screen share: $e'); + // } } void _onTapDisconnect() async {