Skip to content

Commit

Permalink
fix: Prevent ReplayKitChannel related code from being executed on non…
Browse files Browse the repository at this point in the history
…-iOS platforms. (#432)
  • Loading branch information
cloudwebrtc authored Dec 21, 2023
1 parent 35d5cca commit 060ccda
Showing 1 changed file with 16 additions and 9 deletions.
25 changes: 16 additions & 9 deletions example/lib/pages/room.dart
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,9 @@ class _RoomPageState extends State<RoomPage> {
Hardware.instance.setSpeakerphoneOn(true);
}

ReplayKitChannel.listenMethodChannel(widget.room);
if (lkPlatformIs(PlatformType.iOS)) {
ReplayKitChannel.listenMethodChannel(widget.room);
}

if (lkPlatformIsDesktop()) {
onWindowShouldClose = () async {
Expand All @@ -64,7 +66,9 @@ class _RoomPageState extends State<RoomPage> {
void dispose() {
// always dispose listener
(() async {
ReplayKitChannel.closeReplayKit();
if (lkPlatformIs(PlatformType.iOS)) {
ReplayKitChannel.closeReplayKit();
}
widget.room.removeListener(_onRoomDidUpdate);
await _listener.dispose();
await widget.room.dispose();
Expand Down Expand Up @@ -203,22 +207,25 @@ class _RoomPageState extends State<RoomPage> {
if (localParticipantTracks != null) {
for (var t in localParticipantTracks) {
if (t.isScreenShare) {
if (!_flagStartedReplayKit) {
_flagStartedReplayKit = true;
if (lkPlatformIs(PlatformType.iOS)) {
if (!_flagStartedReplayKit) {
_flagStartedReplayKit = true;

ReplayKitChannel.startReplayKit();
ReplayKitChannel.startReplayKit();
}
}

screenTracks.add(ParticipantTrack(
participant: widget.room.localParticipant!,
videoTrack: t.track,
isScreenShare: true,
));
} else {
if (_flagStartedReplayKit) {
_flagStartedReplayKit = false;
if (lkPlatformIs(PlatformType.iOS)) {
if (_flagStartedReplayKit) {
_flagStartedReplayKit = false;

ReplayKitChannel.closeReplayKit();
ReplayKitChannel.closeReplayKit();
}
}

userMediaTracks.add(ParticipantTrack(
Expand Down

0 comments on commit 060ccda

Please sign in to comment.