mirror of https://github.com/OpenVidu/openvidu.git
openvidu-browser: Safari support
parent
12579d5c0f
commit
0400ea3e17
|
@ -202,6 +202,10 @@ export class LocalRecorder {
|
||||||
this.videoPreview.id = this.id;
|
this.videoPreview.id = this.id;
|
||||||
this.videoPreview.autoplay = true;
|
this.videoPreview.autoplay = true;
|
||||||
|
|
||||||
|
if (platform.name === 'Safari' && platform.product === 'iPhone') {
|
||||||
|
this.videoPreview.setAttribute('playsinline', 'true');
|
||||||
|
}
|
||||||
|
|
||||||
if (typeof parentElement === 'string') {
|
if (typeof parentElement === 'string') {
|
||||||
this.htmlParentElementId = parentElement;
|
this.htmlParentElementId = parentElement;
|
||||||
|
|
||||||
|
|
|
@ -77,7 +77,7 @@ export class OpenVidu {
|
||||||
constructor() {
|
constructor() {
|
||||||
console.info("'OpenVidu' initialized");
|
console.info("'OpenVidu' initialized");
|
||||||
|
|
||||||
if (platform.name!!.toLowerCase().indexOf('mobile') !== -1) {
|
if (platform.os!!.family === 'iOS' || platform.os!!.family === 'Android') {
|
||||||
// Listen to orientationchange only on mobile browsers
|
// Listen to orientationchange only on mobile browsers
|
||||||
(<any>window).onorientationchange = () => {
|
(<any>window).onorientationchange = () => {
|
||||||
this.publishers.forEach(publisher => {
|
this.publishers.forEach(publisher => {
|
||||||
|
@ -484,7 +484,7 @@ export class OpenVidu {
|
||||||
(platform.name!.indexOf('Firefox') !== -1 && publisherProperties.videoSource === 'window')) {
|
(platform.name!.indexOf('Firefox') !== -1 && publisherProperties.videoSource === 'window')) {
|
||||||
|
|
||||||
if (platform.name !== 'Chrome' && platform.name!.indexOf('Firefox') === -1 && platform.name !== 'Opera') {
|
if (platform.name !== 'Chrome' && platform.name!.indexOf('Firefox') === -1 && platform.name !== 'Opera') {
|
||||||
const error = new OpenViduError(OpenViduErrorName.SCREEN_SHARING_NOT_SUPPORTED, 'You can only screen share in desktop Chrome and Firefox. Detected browser: ' + platform.name);
|
const error = new OpenViduError(OpenViduErrorName.SCREEN_SHARING_NOT_SUPPORTED, 'You can only screen share in desktop Chrome, Firefox or Opera. Detected browser: ' + platform.name);
|
||||||
console.error(error);
|
console.error(error);
|
||||||
reject(error);
|
reject(error);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -292,6 +292,11 @@ export class Publisher extends StreamManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
this.videoReference = document.createElement('video');
|
this.videoReference = document.createElement('video');
|
||||||
|
|
||||||
|
if (platform.name === 'Safari' && platform.product === 'iPhone') {
|
||||||
|
this.videoReference.setAttribute('playsinline', 'true');
|
||||||
|
}
|
||||||
|
|
||||||
this.videoReference.srcObject = mediaStream;
|
this.videoReference.srcObject = mediaStream;
|
||||||
|
|
||||||
this.stream.setMediaStream(mediaStream);
|
this.stream.setMediaStream(mediaStream);
|
||||||
|
|
|
@ -112,6 +112,9 @@ export class StreamManager implements EventDispatcher {
|
||||||
video: document.createElement('video'),
|
video: document.createElement('video'),
|
||||||
id: ''
|
id: ''
|
||||||
};
|
};
|
||||||
|
if (platform.name === 'Safari' && platform.product === 'iPhone') {
|
||||||
|
this.firstVideoElement.video.setAttribute('playsinline', 'true');
|
||||||
|
}
|
||||||
this.targetElement = targEl;
|
this.targetElement = targEl;
|
||||||
this.element = targEl;
|
this.element = targEl;
|
||||||
}
|
}
|
||||||
|
@ -329,6 +332,11 @@ export class StreamManager implements EventDispatcher {
|
||||||
}
|
}
|
||||||
video.autoplay = true;
|
video.autoplay = true;
|
||||||
video.controls = false;
|
video.controls = false;
|
||||||
|
|
||||||
|
if (platform.name === 'Safari' && platform.product === 'iPhone') {
|
||||||
|
video.setAttribute('playsinline', 'true');
|
||||||
|
}
|
||||||
|
|
||||||
if (!video.id) {
|
if (!video.id) {
|
||||||
video.id = (this.remote ? 'remote-' : 'local-') + 'video-' + this.stream.streamId;
|
video.id = (this.remote ? 'remote-' : 'local-') + 'video-' + this.stream.streamId;
|
||||||
// DEPRECATED property: assign once the property id if the user provided a valid targetElement
|
// DEPRECATED property: assign once the property id if the user provided a valid targetElement
|
||||||
|
|
|
@ -29,7 +29,7 @@ export interface WebRtcPeerConfiguration {
|
||||||
onicecandidate: (event) => void;
|
onicecandidate: (event) => void;
|
||||||
iceServers: RTCIceServer[] | undefined;
|
iceServers: RTCIceServer[] | undefined;
|
||||||
mediaStream?: MediaStream;
|
mediaStream?: MediaStream;
|
||||||
mode?: string; // sendonly, reconly, sendrecv
|
mode?: 'sendonly' | 'recvonly' | 'sendrecv';
|
||||||
id?: string;
|
id?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -154,6 +154,38 @@ export class WebRtcPeer {
|
||||||
|
|
||||||
console.debug('RTCPeerConnection constraints: ' + JSON.stringify(constraints));
|
console.debug('RTCPeerConnection constraints: ' + JSON.stringify(constraints));
|
||||||
|
|
||||||
|
if (platform.name === 'Safari') {
|
||||||
|
// Safari, at least on iOS just seems to support unified plan, whereas in other browsers is not yet ready and considered experimental
|
||||||
|
if (offerAudio) {
|
||||||
|
this.pc.addTransceiver('audio', {
|
||||||
|
direction: this.configuration.mode,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (offerVideo) {
|
||||||
|
this.pc.addTransceiver('video', {
|
||||||
|
direction: this.configuration.mode,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
this.pc
|
||||||
|
.createOffer()
|
||||||
|
.then(offer => {
|
||||||
|
console.debug('Created SDP offer');
|
||||||
|
return this.pc.setLocalDescription(offer);
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
const localDescription = this.pc.localDescription;
|
||||||
|
|
||||||
|
if (!!localDescription) {
|
||||||
|
console.debug('Local description set', localDescription.sdp);
|
||||||
|
resolve(localDescription.sdp);
|
||||||
|
} else {
|
||||||
|
reject('Local description is not defined');
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch(error => reject(error));
|
||||||
|
} else {
|
||||||
this.pc.createOffer(constraints).then(offer => {
|
this.pc.createOffer(constraints).then(offer => {
|
||||||
console.debug('Created SDP offer');
|
console.debug('Created SDP offer');
|
||||||
return this.pc.setLocalDescription(offer);
|
return this.pc.setLocalDescription(offer);
|
||||||
|
@ -161,11 +193,13 @@ export class WebRtcPeer {
|
||||||
const localDescription = this.pc.localDescription;
|
const localDescription = this.pc.localDescription;
|
||||||
if (!!localDescription) {
|
if (!!localDescription) {
|
||||||
console.debug('Local description set', localDescription.sdp);
|
console.debug('Local description set', localDescription.sdp);
|
||||||
resolve(<string>localDescription.sdp);
|
resolve(localDescription.sdp);
|
||||||
} else {
|
} else {
|
||||||
reject('Local description is not defined');
|
reject('Local description is not defined');
|
||||||
}
|
}
|
||||||
}).catch(error => reject(error));
|
})
|
||||||
|
.catch(error => reject(error));
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue