Skip to content

Commit

Permalink
fix(MeetingsJsonAdapter): prevent camera usage on iOS 15.1 due to iOS…
Browse files Browse the repository at this point in the history
… bug
  • Loading branch information
patricia0817 authored and cipak committed Mar 30, 2022
1 parent 0bc05b0 commit beb3ef0
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 9 deletions.
24 changes: 17 additions & 7 deletions src/adapters/MeetingsJSONAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ const EMPTY_MEETING = {
speakerID: null,
};

const ON_IOS_15_1 = typeof navigator !== 'undefined'
&& navigator.userAgent.includes('iPhone OS 15_1');

// Adapter Events
const EVENT_MEETING_UPDATE = 'meeting:update';

Expand Down Expand Up @@ -394,6 +397,13 @@ export default class MeetingsJSONAdapter extends MeetingsAdapter {
let deviceId;
let perm;

if (constraints.video && ON_IOS_15_1) {
return {
stream: null,
perm: 'ERROR',
};
}

try {
const mediaStream = await navigator.mediaDevices.getUserMedia(constraints);
const availableDevices = await this.getAvailableDevices();
Expand All @@ -411,20 +421,20 @@ export default class MeetingsJSONAdapter extends MeetingsAdapter {
}

perm = 'ALLOWED';
} catch (error) {
} catch (err) {
// eslint-disable-next-line no-console
console.error('Meetings JSON adapter can not display the local user stream', error);
console.error('Meetings JSON adapter can not display the local user stream', err);

if (error instanceof DOMException) {
if (error.name === 'NotAllowedError') {
if (error.message === 'Permission dismissed') {
if (err instanceof DOMException) {
if (err.name === 'NotAllowedError') {
if (err.message === 'Permission dismissed') {
perm = 'DISMISSED';
} else if (error.message === 'Permission denied by system') {
} else if (err.message === 'Permission denied by system') {
perm = 'DISABLED';
} else {
perm = 'DENIED';
}
} else if (error.name === 'NotReadableError') {
} else if (err.name === 'NotReadableError') {
perm = 'DISABLED';
} else {
perm = 'ERROR';
Expand Down
16 changes: 14 additions & 2 deletions src/adapters/MeetingsJSONAdapter/controls/MuteVideoControl.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {Observable} from 'rxjs';
import {Observable, of} from 'rxjs';
import {map, distinctUntilChanged} from 'rxjs/operators';
import {MeetingControlState} from '@webex/component-adapter-interfaces';
import MeetingControl from './MeetingControl';
Expand Down Expand Up @@ -45,7 +45,19 @@ export default class MuteVideoControl extends MeetingControl {
text: 'Stop video',
};

return this.adapter.getMeeting(meetingID).pipe(
const notSupported = {
ID: this.ID,
type: 'BUTTON',
icon: 'camera-muted',
tooltip: 'Video not supported on iOS 15.1',
state: MeetingControlState.DISABLED,
text: 'No camera',
};

const ON_IOS_15_1 = typeof navigator !== 'undefined'
&& navigator.userAgent.includes('iPhone OS 15_1');

return ON_IOS_15_1 ? of(notSupported) : this.adapter.getMeeting(meetingID).pipe(
map((meeting) => !!meeting.localVideo.stream),
distinctUntilChanged(),
map((localVideoExists) => (localVideoExists ? unmuted : muted)),
Expand Down

0 comments on commit beb3ef0

Please sign in to comment.