openvidu/openvidu-browser/lib/OpenVidu/Publisher.js

490 lines
28 KiB
JavaScript
Raw Normal View History

2018-04-26 15:33:47 +02:00
"use strict";
/*
* (C) Copyright 2017-2018 OpenVidu (https://openvidu.io/)
2018-04-26 15:33:47 +02:00
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
2018-06-01 14:39:38 +02:00
var __extends = (this && this.__extends) || (function () {
var extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
2018-04-26 15:33:47 +02:00
exports.__esModule = true;
2018-06-01 14:39:38 +02:00
var Session_1 = require("./Session");
var Stream_1 = require("./Stream");
2018-06-01 14:39:38 +02:00
var StreamManager_1 = require("./StreamManager");
2018-04-26 15:33:47 +02:00
var StreamEvent_1 = require("../OpenViduInternal/Events/StreamEvent");
2018-07-11 11:47:53 +02:00
var StreamPropertyChangedEvent_1 = require("../OpenViduInternal/Events/StreamPropertyChangedEvent");
2018-04-26 15:33:47 +02:00
var VideoElementEvent_1 = require("../OpenViduInternal/Events/VideoElementEvent");
var OpenViduError_1 = require("../OpenViduInternal/Enums/OpenViduError");
2018-07-11 11:47:53 +02:00
var platform = require("platform");
2018-04-26 15:33:47 +02:00
/**
* Packs local media streams. Participants can publish it to a session. Initialized with [[OpenVidu.initPublisher]] method
*/
2018-06-01 14:39:38 +02:00
var Publisher = /** @class */ (function (_super) {
__extends(Publisher, _super);
2018-04-26 15:33:47 +02:00
/**
* @hidden
*/
2018-06-01 14:39:38 +02:00
function Publisher(targEl, properties, openvidu) {
var _this = _super.call(this, new Stream_1.Stream((!!openvidu.session) ? openvidu.session : new Session_1.Session(openvidu), { publisherProperties: properties, mediaConstraints: {} }), targEl) || this;
2018-04-26 15:33:47 +02:00
/**
* Whether the Publisher has been granted access to the requested input devices or not
*/
2018-06-01 14:39:38 +02:00
_this.accessAllowed = false;
/**
* Whether you have called [[Publisher.subscribeToRemote]] with value `true` or `false` (*false* by default)
*/
_this.isSubscribedToRemote = false;
_this.accessDenied = false;
_this.properties = properties;
2018-07-11 11:47:53 +02:00
_this.openvidu = openvidu;
_this.stream.ee.on('local-stream-destroyed', function (reason) {
_this.stream.isLocalStreamPublished = false;
2018-04-26 15:33:47 +02:00
var streamEvent = new StreamEvent_1.StreamEvent(true, _this, 'streamDestroyed', _this.stream, reason);
2018-07-11 11:47:53 +02:00
_this.emitEvent('streamDestroyed', [streamEvent]);
streamEvent.callDefaultBehavior();
2018-04-26 15:33:47 +02:00
});
2018-06-01 14:39:38 +02:00
return _this;
2018-04-26 15:33:47 +02:00
}
/**
* Publish or unpublish the audio stream (if available). Calling this method twice in a row passing same value will have no effect
2018-07-11 11:47:53 +02:00
*
* #### Events dispatched
*
* The [[Session]] object of the local participant will dispatch a `streamPropertyChanged` event with `changedProperty` set to `"audioActive"` and `reason` set to `"publishAudio"`
* The [[Publisher]] object of the local participant will also dispatch the exact same event
*
* The [[Session]] object of every other participant connected to the session will dispatch a `streamPropertyChanged` event with `changedProperty` set to `"audioActive"` and `reason` set to `"publishAudio"`
* The respective [[Subscriber]] object of every other participant receiving this Publisher's stream will also dispatch the exact same event
*
* See [[StreamPropertyChangedEvent]] to learn more.
*
2018-04-26 15:33:47 +02:00
* @param value `true` to publish the audio stream, `false` to unpublish it
*/
Publisher.prototype.publishAudio = function (value) {
2018-07-11 11:47:53 +02:00
var _this = this;
if (this.stream.audioActive !== value) {
this.stream.getMediaStream().getAudioTracks().forEach(function (track) {
track.enabled = value;
});
this.session.openvidu.sendRequest('streamPropertyChanged', {
streamId: this.stream.streamId,
property: 'audioActive',
newValue: value,
reason: 'publishAudio'
}, function (error, response) {
if (error) {
console.error("Error sending 'streamPropertyChanged' event", error);
}
else {
_this.session.emitEvent('streamPropertyChanged', [new StreamPropertyChangedEvent_1.StreamPropertyChangedEvent(_this.session, _this.stream, 'audioActive', value, !value, 'publishAudio')]);
_this.emitEvent('streamPropertyChanged', [new StreamPropertyChangedEvent_1.StreamPropertyChangedEvent(_this, _this.stream, 'audioActive', value, !value, 'publishAudio')]);
}
});
this.stream.audioActive = value;
console.info("'Publisher' has " + (value ? 'published' : 'unpublished') + ' its audio stream');
}
2018-04-26 15:33:47 +02:00
};
/**
* Publish or unpublish the video stream (if available). Calling this method twice in a row passing same value will have no effect
2018-07-11 11:47:53 +02:00
*
* #### Events dispatched
*
* The [[Session]] object of the local participant will dispatch a `streamPropertyChanged` event with `changedProperty` set to `"videoActive"` and `reason` set to `"publishVideo"`
* The [[Publisher]] object of the local participant will also dispatch the exact same event
*
* The [[Session]] object of every other participant connected to the session will dispatch a `streamPropertyChanged` event with `changedProperty` set to `"videoActive"` and `reason` set to `"publishVideo"`
* The respective [[Subscriber]] object of every other participant receiving this Publisher's stream will also dispatch the exact same event
*
* See [[StreamPropertyChangedEvent]] to learn more.
*
2018-04-26 15:33:47 +02:00
* @param value `true` to publish the video stream, `false` to unpublish it
*/
Publisher.prototype.publishVideo = function (value) {
2018-07-11 11:47:53 +02:00
var _this = this;
if (this.stream.videoActive !== value) {
this.stream.getMediaStream().getVideoTracks().forEach(function (track) {
track.enabled = value;
});
this.session.openvidu.sendRequest('streamPropertyChanged', {
streamId: this.stream.streamId,
property: 'videoActive',
newValue: value,
reason: 'publishVideo'
}, function (error, response) {
if (error) {
console.error("Error sending 'streamPropertyChanged' event", error);
}
else {
_this.session.emitEvent('streamPropertyChanged', [new StreamPropertyChangedEvent_1.StreamPropertyChangedEvent(_this.session, _this.stream, 'videoActive', value, !value, 'publishVideo')]);
_this.emitEvent('streamPropertyChanged', [new StreamPropertyChangedEvent_1.StreamPropertyChangedEvent(_this, _this.stream, 'videoActive', value, !value, 'publishVideo')]);
}
});
this.stream.videoActive = value;
console.info("'Publisher' has " + (value ? 'published' : 'unpublished') + ' its video stream');
}
2018-04-26 15:33:47 +02:00
};
/**
2018-07-11 11:47:53 +02:00
* Call this method before [[Session.publish]] if you prefer to subscribe to your Publisher's remote stream instead of using the local stream, as any other user would do.
2018-04-26 15:33:47 +02:00
*/
2018-06-01 14:39:38 +02:00
Publisher.prototype.subscribeToRemote = function (value) {
value = (value !== undefined) ? value : true;
this.isSubscribedToRemote = value;
this.stream.subscribeToMyRemote(value);
2018-04-26 15:33:47 +02:00
};
/**
* See [[EventDispatcher.on]]
*/
Publisher.prototype.on = function (type, handler) {
var _this = this;
2018-06-01 14:39:38 +02:00
_super.prototype.on.call(this, type, handler);
2018-04-26 15:33:47 +02:00
if (type === 'streamCreated') {
2018-06-01 14:39:38 +02:00
if (!!this.stream && this.stream.isLocalStreamPublished) {
2018-07-11 11:47:53 +02:00
this.emitEvent('streamCreated', [new StreamEvent_1.StreamEvent(false, this, 'streamCreated', this.stream, '')]);
2018-04-26 15:33:47 +02:00
}
else {
2018-06-01 14:39:38 +02:00
this.stream.ee.on('stream-created-by-publisher', function () {
2018-07-11 11:47:53 +02:00
_this.emitEvent('streamCreated', [new StreamEvent_1.StreamEvent(false, _this, 'streamCreated', _this.stream, '')]);
2018-04-26 15:33:47 +02:00
});
}
}
if (type === 'remoteVideoPlaying') {
2018-06-01 14:39:38 +02:00
if (this.stream.displayMyRemote() && this.videos[0] && this.videos[0].video &&
this.videos[0].video.currentTime > 0 &&
this.videos[0].video.paused === false &&
this.videos[0].video.ended === false &&
this.videos[0].video.readyState === 4) {
2018-07-11 11:47:53 +02:00
this.emitEvent('remoteVideoPlaying', [new VideoElementEvent_1.VideoElementEvent(this.videos[0].video, this, 'remoteVideoPlaying')]);
2018-04-26 15:33:47 +02:00
}
}
if (type === 'accessAllowed') {
2018-06-01 14:39:38 +02:00
if (this.accessAllowed) {
2018-07-11 11:47:53 +02:00
this.emitEvent('accessAllowed', []);
2018-04-26 15:33:47 +02:00
}
}
if (type === 'accessDenied') {
2018-06-01 14:39:38 +02:00
if (this.accessDenied) {
2018-07-11 11:47:53 +02:00
this.emitEvent('accessDenied', []);
2018-04-26 15:33:47 +02:00
}
}
return this;
};
/**
* See [[EventDispatcher.once]]
*/
Publisher.prototype.once = function (type, handler) {
var _this = this;
2018-06-01 14:39:38 +02:00
_super.prototype.once.call(this, type, handler);
2018-04-26 15:33:47 +02:00
if (type === 'streamCreated') {
2018-06-01 14:39:38 +02:00
if (!!this.stream && this.stream.isLocalStreamPublished) {
2018-07-11 11:47:53 +02:00
this.emitEvent('streamCreated', [new StreamEvent_1.StreamEvent(false, this, 'streamCreated', this.stream, '')]);
2018-04-26 15:33:47 +02:00
}
else {
2018-06-01 14:39:38 +02:00
this.stream.ee.once('stream-created-by-publisher', function () {
2018-07-11 11:47:53 +02:00
_this.emitEvent('streamCreated', [new StreamEvent_1.StreamEvent(false, _this, 'streamCreated', _this.stream, '')]);
2018-04-26 15:33:47 +02:00
});
}
}
if (type === 'remoteVideoPlaying') {
2018-06-01 14:39:38 +02:00
if (this.stream.displayMyRemote() && this.videos[0] && this.videos[0].video &&
this.videos[0].video.currentTime > 0 &&
this.videos[0].video.paused === false &&
this.videos[0].video.ended === false &&
this.videos[0].video.readyState === 4) {
2018-07-11 11:47:53 +02:00
this.emitEvent('remoteVideoPlaying', [new VideoElementEvent_1.VideoElementEvent(this.videos[0].video, this, 'remoteVideoPlaying')]);
2018-04-26 15:33:47 +02:00
}
}
if (type === 'accessAllowed') {
2018-06-01 14:39:38 +02:00
if (this.accessAllowed) {
2018-07-11 11:47:53 +02:00
this.emitEvent('accessAllowed', []);
2018-04-26 15:33:47 +02:00
}
}
if (type === 'accessDenied') {
2018-06-01 14:39:38 +02:00
if (this.accessDenied) {
2018-07-11 11:47:53 +02:00
this.emitEvent('accessDenied', []);
2018-04-26 15:33:47 +02:00
}
}
return this;
};
/* Hidden methods */
/**
* @hidden
*/
Publisher.prototype.initialize = function () {
var _this = this;
return new Promise(function (resolve, reject) {
var errorCallback = function (openViduError) {
2018-06-01 14:39:38 +02:00
_this.accessDenied = true;
_this.accessAllowed = false;
2018-04-26 15:33:47 +02:00
reject(openViduError);
};
var successCallback = function (mediaStream) {
2018-06-01 14:39:38 +02:00
_this.accessAllowed = true;
_this.accessDenied = false;
2018-04-26 15:33:47 +02:00
if (_this.openvidu.isMediaStreamTrack(_this.properties.audioSource)) {
mediaStream.removeTrack(mediaStream.getAudioTracks()[0]);
mediaStream.addTrack(_this.properties.audioSource);
}
if (_this.openvidu.isMediaStreamTrack(_this.properties.videoSource)) {
mediaStream.removeTrack(mediaStream.getVideoTracks()[0]);
mediaStream.addTrack(_this.properties.videoSource);
}
// Apply PublisherProperties.publishAudio and PublisherProperties.publishVideo
if (!!mediaStream.getAudioTracks()[0]) {
2018-07-23 11:37:18 +02:00
var enabled = (_this.stream.audioActive !== undefined && _this.stream.audioActive !== null) ? _this.stream.audioActive : !!_this.stream.outboundStreamOpts.publisherProperties.publishAudio;
mediaStream.getAudioTracks()[0].enabled = enabled;
2018-04-26 15:33:47 +02:00
}
if (!!mediaStream.getVideoTracks()[0]) {
2018-07-23 11:37:18 +02:00
var enabled = (_this.stream.videoActive !== undefined && _this.stream.videoActive !== null) ? _this.stream.videoActive : !!_this.stream.outboundStreamOpts.publisherProperties.publishVideo;
mediaStream.getVideoTracks()[0].enabled = enabled;
2018-04-26 15:33:47 +02:00
}
2018-07-11 11:47:53 +02:00
_this.videoReference = document.createElement('video');
_this.videoReference.srcObject = mediaStream;
2018-04-26 15:33:47 +02:00
_this.stream.setMediaStream(mediaStream);
2018-06-01 14:39:38 +02:00
if (!_this.stream.displayMyRemote()) {
// When we are subscribed to our remote we don't still set the MediaStream object in the video elements to
// avoid early 'streamPlaying' event
_this.stream.updateMediaStreamInVideos();
}
if (!!_this.firstVideoElement) {
_this.createVideoElement(_this.firstVideoElement.targetElement, _this.properties.insertMode);
}
delete _this.firstVideoElement;
2018-07-11 11:47:53 +02:00
if (_this.stream.isSendVideo()) {
if (!_this.stream.isSendScreen()) {
// With no screen share, video dimension can be set directly from MediaStream (getSettings)
// Orientation must be checked for mobile devices (width and height are reversed)
var _a = mediaStream.getVideoTracks()[0].getSettings(), width = _a.width, height = _a.height;
if (platform.name.toLowerCase().indexOf('mobile') !== -1 && (window.innerHeight > window.innerWidth)) {
// Mobile portrait mode
_this.stream.videoDimensions = {
width: height || 0,
height: width || 0
};
}
else {
_this.stream.videoDimensions = {
width: width || 0,
height: height || 0
};
}
_this.stream.isLocalStreamReadyToPublish = true;
_this.stream.ee.emitEvent('stream-ready-to-publish', []);
}
else {
// With screen share, video dimension must be got from a video element (onloadedmetadata event)
_this.videoReference.onloadedmetadata = function () {
_this.stream.videoDimensions = {
width: _this.videoReference.videoWidth,
height: _this.videoReference.videoHeight
};
_this.screenShareResizeInterval = setInterval(function () {
var firefoxSettings = mediaStream.getVideoTracks()[0].getSettings();
var newWidth = (platform.name === 'Chrome') ? _this.videoReference.videoWidth : firefoxSettings.width;
var newHeight = (platform.name === 'Chrome') ? _this.videoReference.videoHeight : firefoxSettings.height;
if (_this.stream.isLocalStreamPublished &&
(newWidth !== _this.stream.videoDimensions.width ||
newHeight !== _this.stream.videoDimensions.height)) {
var oldValue_1 = { width: _this.stream.videoDimensions.width, height: _this.stream.videoDimensions.height };
_this.stream.videoDimensions = {
width: newWidth || 0,
height: newHeight || 0
};
_this.session.openvidu.sendRequest('streamPropertyChanged', {
streamId: _this.stream.streamId,
property: 'videoDimensions',
newValue: JSON.stringify(_this.stream.videoDimensions),
reason: 'screenResized'
}, function (error, response) {
if (error) {
console.error("Error sending 'streamPropertyChanged' event", error);
}
else {
_this.session.emitEvent('streamPropertyChanged', [new StreamPropertyChangedEvent_1.StreamPropertyChangedEvent(_this.session, _this.stream, 'videoDimensions', _this.stream.videoDimensions, oldValue_1, 'screenResized')]);
_this.emitEvent('streamPropertyChanged', [new StreamPropertyChangedEvent_1.StreamPropertyChangedEvent(_this, _this.stream, 'videoDimensions', _this.stream.videoDimensions, oldValue_1, 'screenResized')]);
}
});
}
}, 500);
_this.stream.isLocalStreamReadyToPublish = true;
_this.stream.ee.emitEvent('stream-ready-to-publish', []);
};
}
}
else {
_this.stream.isLocalStreamReadyToPublish = true;
_this.stream.ee.emitEvent('stream-ready-to-publish', []);
}
2018-04-26 15:33:47 +02:00
resolve();
};
_this.openvidu.generateMediaConstraints(_this.properties)
.then(function (constraints) {
var outboundStreamOptions = {
mediaConstraints: constraints,
publisherProperties: _this.properties
};
_this.stream.setOutboundStreamOptions(outboundStreamOptions);
var constraintsAux = {};
2018-05-03 11:48:57 +02:00
var timeForDialogEvent = 1250;
2018-06-01 14:39:38 +02:00
if (_this.stream.isSendVideo() || _this.stream.isSendAudio()) {
var definedAudioConstraint_1 = ((constraints.audio === undefined) ? true : constraints.audio);
constraintsAux.audio = _this.stream.isSendScreen() ? false : definedAudioConstraint_1;
2018-04-26 15:33:47 +02:00
constraintsAux.video = constraints.video;
var startTime_1 = Date.now();
_this.setPermissionDialogTimer(timeForDialogEvent);
navigator.mediaDevices.getUserMedia(constraintsAux)
2018-06-01 14:39:38 +02:00
.then(function (mediaStream) {
2018-04-26 15:33:47 +02:00
_this.clearPermissionDialogTimer(startTime_1, timeForDialogEvent);
2018-06-01 14:39:38 +02:00
if (_this.stream.isSendScreen() && _this.stream.isSendAudio()) {
// When getting desktop as user media audio constraint must be false. Now we can ask for it if required
constraintsAux.audio = definedAudioConstraint_1;
2018-04-26 15:33:47 +02:00
constraintsAux.video = false;
startTime_1 = Date.now();
_this.setPermissionDialogTimer(timeForDialogEvent);
navigator.mediaDevices.getUserMedia(constraintsAux)
.then(function (audioOnlyStream) {
_this.clearPermissionDialogTimer(startTime_1, timeForDialogEvent);
2018-06-01 14:39:38 +02:00
mediaStream.addTrack(audioOnlyStream.getAudioTracks()[0]);
successCallback(mediaStream);
2018-04-26 15:33:47 +02:00
})["catch"](function (error) {
_this.clearPermissionDialogTimer(startTime_1, timeForDialogEvent);
2018-06-01 14:39:38 +02:00
var errorName, errorMessage;
2018-04-26 15:33:47 +02:00
switch (error.name.toLowerCase()) {
case 'notfounderror':
errorName = OpenViduError_1.OpenViduErrorName.INPUT_AUDIO_DEVICE_NOT_FOUND;
errorMessage = error.toString();
2018-06-01 14:39:38 +02:00
errorCallback(new OpenViduError_1.OpenViduError(errorName, errorMessage));
2018-04-26 15:33:47 +02:00
break;
case 'notallowederror':
2018-06-01 14:39:38 +02:00
errorName = OpenViduError_1.OpenViduErrorName.DEVICE_ACCESS_DENIED;
2018-04-26 15:33:47 +02:00
errorMessage = error.toString();
2018-06-01 14:39:38 +02:00
errorCallback(new OpenViduError_1.OpenViduError(errorName, errorMessage));
2018-04-26 15:33:47 +02:00
break;
case 'overconstrainederror':
if (error.constraint.toLowerCase() === 'deviceid') {
errorName = OpenViduError_1.OpenViduErrorName.INPUT_AUDIO_DEVICE_NOT_FOUND;
2018-06-01 14:39:38 +02:00
errorMessage = "Audio input device with deviceId '" + constraints.video.deviceId.exact + "' not found";
2018-04-26 15:33:47 +02:00
}
else {
errorName = OpenViduError_1.OpenViduErrorName.PUBLISHER_PROPERTIES_ERROR;
errorMessage = "Audio input device doesn't support the value passed for constraint '" + error.constraint + "'";
}
2018-06-01 14:39:38 +02:00
errorCallback(new OpenViduError_1.OpenViduError(errorName, errorMessage));
break;
2018-04-26 15:33:47 +02:00
}
});
}
else {
2018-06-01 14:39:38 +02:00
successCallback(mediaStream);
2018-04-26 15:33:47 +02:00
}
})["catch"](function (error) {
_this.clearPermissionDialogTimer(startTime_1, timeForDialogEvent);
2018-06-01 14:39:38 +02:00
var errorName, errorMessage;
2018-04-26 15:33:47 +02:00
switch (error.name.toLowerCase()) {
case 'notfounderror':
2018-06-01 14:39:38 +02:00
navigator.mediaDevices.getUserMedia({
audio: false,
video: constraints.video
})
.then(function (mediaStream) {
mediaStream.getVideoTracks().forEach(function (track) {
track.stop();
});
errorName = OpenViduError_1.OpenViduErrorName.INPUT_AUDIO_DEVICE_NOT_FOUND;
errorMessage = error.toString();
errorCallback(new OpenViduError_1.OpenViduError(errorName, errorMessage));
})["catch"](function (e) {
2018-04-26 15:33:47 +02:00
errorName = OpenViduError_1.OpenViduErrorName.INPUT_VIDEO_DEVICE_NOT_FOUND;
2018-06-01 14:39:38 +02:00
errorMessage = error.toString();
errorCallback(new OpenViduError_1.OpenViduError(errorName, errorMessage));
});
2018-04-26 15:33:47 +02:00
break;
case 'notallowederror':
2018-06-01 14:39:38 +02:00
errorName = _this.stream.isSendScreen() ? OpenViduError_1.OpenViduErrorName.SCREEN_CAPTURE_DENIED : OpenViduError_1.OpenViduErrorName.DEVICE_ACCESS_DENIED;
2018-04-26 15:33:47 +02:00
errorMessage = error.toString();
2018-06-01 14:39:38 +02:00
errorCallback(new OpenViduError_1.OpenViduError(errorName, errorMessage));
2018-04-26 15:33:47 +02:00
break;
case 'overconstrainederror':
2018-06-01 14:39:38 +02:00
navigator.mediaDevices.getUserMedia({
audio: false,
video: constraints.video
})
.then(function (mediaStream) {
mediaStream.getVideoTracks().forEach(function (track) {
track.stop();
});
if (error.constraint.toLowerCase() === 'deviceid') {
errorName = OpenViduError_1.OpenViduErrorName.INPUT_AUDIO_DEVICE_NOT_FOUND;
errorMessage = "Audio input device with deviceId '" + constraints.audio.deviceId.exact + "' not found";
}
else {
errorName = OpenViduError_1.OpenViduErrorName.PUBLISHER_PROPERTIES_ERROR;
errorMessage = "Audio input device doesn't support the value passed for constraint '" + error.constraint + "'";
}
errorCallback(new OpenViduError_1.OpenViduError(errorName, errorMessage));
})["catch"](function (e) {
if (error.constraint.toLowerCase() === 'deviceid') {
errorName = OpenViduError_1.OpenViduErrorName.INPUT_VIDEO_DEVICE_NOT_FOUND;
errorMessage = "Video input device with deviceId '" + constraints.video.deviceId.exact + "' not found";
}
else {
errorName = OpenViduError_1.OpenViduErrorName.PUBLISHER_PROPERTIES_ERROR;
errorMessage = "Video input device doesn't support the value passed for constraint '" + error.constraint + "'";
}
errorCallback(new OpenViduError_1.OpenViduError(errorName, errorMessage));
});
break;
2018-04-26 15:33:47 +02:00
}
});
}
else {
reject(new OpenViduError_1.OpenViduError(OpenViduError_1.OpenViduErrorName.NO_INPUT_SOURCE_SET, "Properties 'audioSource' and 'videoSource' cannot be set to false or null at the same time when calling 'OpenVidu.initPublisher'"));
}
})["catch"](function (error) {
errorCallback(error);
});
});
};
2018-06-01 14:39:38 +02:00
/**
* @hidden
*/
Publisher.prototype.reestablishStreamPlayingEvent = function () {
if (this.ee.getListeners('streamPlaying').length > 0) {
this.addPlayEventToFirstVideo();
}
};
2018-04-26 15:33:47 +02:00
/* Private methods */
Publisher.prototype.setPermissionDialogTimer = function (waitTime) {
var _this = this;
this.permissionDialogTimeout = setTimeout(function () {
2018-07-11 11:47:53 +02:00
_this.emitEvent('accessDialogOpened', []);
2018-04-26 15:33:47 +02:00
}, waitTime);
};
Publisher.prototype.clearPermissionDialogTimer = function (startTime, waitTime) {
clearTimeout(this.permissionDialogTimeout);
if ((Date.now() - startTime) > waitTime) {
// Permission dialog was shown and now is closed
2018-07-11 11:47:53 +02:00
this.emitEvent('accessDialogClosed', []);
2018-04-26 15:33:47 +02:00
}
};
return Publisher;
2018-06-01 14:39:38 +02:00
}(StreamManager_1.StreamManager));
2018-04-26 15:33:47 +02:00
exports.Publisher = Publisher;
//# sourceMappingURL=Publisher.js.map