Skip to content

Commit 060ccda

Browse files
authored
fix: Prevent ReplayKitChannel related code from being executed on non-iOS platforms. (#432)
1 parent 35d5cca commit 060ccda

File tree

1 file changed

+16
-9
lines changed

1 file changed

+16
-9
lines changed

example/lib/pages/room.dart

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,9 @@ class _RoomPageState extends State<RoomPage> {
4949
Hardware.instance.setSpeakerphoneOn(true);
5050
}
5151

52-
ReplayKitChannel.listenMethodChannel(widget.room);
52+
if (lkPlatformIs(PlatformType.iOS)) {
53+
ReplayKitChannel.listenMethodChannel(widget.room);
54+
}
5355

5456
if (lkPlatformIsDesktop()) {
5557
onWindowShouldClose = () async {
@@ -64,7 +66,9 @@ class _RoomPageState extends State<RoomPage> {
6466
void dispose() {
6567
// always dispose listener
6668
(() async {
67-
ReplayKitChannel.closeReplayKit();
69+
if (lkPlatformIs(PlatformType.iOS)) {
70+
ReplayKitChannel.closeReplayKit();
71+
}
6872
widget.room.removeListener(_onRoomDidUpdate);
6973
await _listener.dispose();
7074
await widget.room.dispose();
@@ -203,22 +207,25 @@ class _RoomPageState extends State<RoomPage> {
203207
if (localParticipantTracks != null) {
204208
for (var t in localParticipantTracks) {
205209
if (t.isScreenShare) {
206-
if (!_flagStartedReplayKit) {
207-
_flagStartedReplayKit = true;
210+
if (lkPlatformIs(PlatformType.iOS)) {
211+
if (!_flagStartedReplayKit) {
212+
_flagStartedReplayKit = true;
208213

209-
ReplayKitChannel.startReplayKit();
214+
ReplayKitChannel.startReplayKit();
215+
}
210216
}
211-
212217
screenTracks.add(ParticipantTrack(
213218
participant: widget.room.localParticipant!,
214219
videoTrack: t.track,
215220
isScreenShare: true,
216221
));
217222
} else {
218-
if (_flagStartedReplayKit) {
219-
_flagStartedReplayKit = false;
223+
if (lkPlatformIs(PlatformType.iOS)) {
224+
if (_flagStartedReplayKit) {
225+
_flagStartedReplayKit = false;
220226

221-
ReplayKitChannel.closeReplayKit();
227+
ReplayKitChannel.closeReplayKit();
228+
}
222229
}
223230

224231
userMediaTracks.add(ParticipantTrack(

0 commit comments

Comments
 (0)