webpackJsonp([1,4],{ /***/ 104: /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var EventEmitter = __webpack_require__(52); var kurentoUtils = __webpack_require__(275); var adapter = __webpack_require__(173); if (window) { window["adapter"] = adapter; } function jq(id) { return id.replace(/(@|:|\.|\[|\]|,)/g, "\\$1"); } function show(id) { document.getElementById(jq(id)).style.display = 'block'; } function hide(id) { document.getElementById(jq(id)).style.display = 'none'; } var Stream = (function () { function Stream(openVidu, local, room, options) { var _this = this; this.openVidu = openVidu; this.local = local; this.room = room; this.ee = new EventEmitter(); this.videoElements = []; this.elements = []; this.showMyRemote = false; this.localMirrored = false; this.chanId = 0; this.dataChannelOpened = false; this.audioOnly = false; this.isReady = false; this.isVideoELementCreated = false; this.accessIsAllowed = false; this.accessIsDenied = false; if (options.id) { this.id = options.id; } else { this.id = "webcam"; } this.connection = options.connection; this.recvVideo = options.recvVideo; this.recvAudio = options.recvAudio; this.dataChannel = options.data || false; this.sendVideo = options.video; this.sendAudio = options.audio; this.mediaConstraints = options.mediaConstraints; this.audioOnly = options.audioOnly || false; this.addEventListener('src-added', function (srcEvent) { _this.videoSrc = srcEvent.src; if (_this.video) _this.video.src = srcEvent.src; console.warn("Videosrc [" + srcEvent.src + "] added to stream [" + _this.getId() + "]"); }); } Stream.prototype.emitSrcEvent = function (wrstream) { this.ee.emitEvent('src-added', [{ src: URL.createObjectURL(wrstream) }]); }; Stream.prototype.emitStreamReadyEvent = function () { this.ee.emitEvent('stream-ready'), [{}]; }; Stream.prototype.getVideoSrc = function () { return this.videoSrc; }; Stream.prototype.removeVideo = function (parentElement) { if (typeof parentElement === "string") { document.getElementById(parentElement).removeChild(this.video); } else if (parentElement instanceof Element) { parentElement.removeChild(this.video); } else if (!parentElement) { if (document.getElementById(this.parentId)) { document.getElementById(this.parentId).removeChild(this.video); } } }; Stream.prototype.getVideoElement = function () { return this.video; }; Stream.prototype.setVideoElement = function (video) { this.video = video; }; Stream.prototype.getRecvVideo = function () { return this.recvVideo; }; Stream.prototype.getRecvAudio = function () { return this.recvAudio; }; Stream.prototype.subscribeToMyRemote = function () { this.showMyRemote = true; }; Stream.prototype.displayMyRemote = function () { return this.showMyRemote; }; Stream.prototype.mirrorLocalStream = function (wr) { this.showMyRemote = true; this.localMirrored = true; if (wr) { this.wrStream = wr; this.emitSrcEvent(this.wrStream); } }; Stream.prototype.isLocalMirrored = function () { return this.localMirrored; }; Stream.prototype.getChannelName = function () { return this.getId() + '_' + this.chanId++; }; Stream.prototype.isDataChannelEnabled = function () { return this.dataChannel; }; Stream.prototype.isDataChannelOpened = function () { return this.dataChannelOpened; }; Stream.prototype.onDataChannelOpen = function (event) { console.log('Data channel is opened'); this.dataChannelOpened = true; }; Stream.prototype.onDataChannelClosed = function (event) { console.log('Data channel is closed'); this.dataChannelOpened = false; }; Stream.prototype.sendData = function (data) { if (this.wp === undefined) { throw new Error('WebRTC peer has not been created yet'); } if (!this.dataChannelOpened) { throw new Error('Data channel is not opened'); } console.log("Sending through data channel: " + data); this.wp.send(data); }; Stream.prototype.getWrStream = function () { return this.wrStream; }; Stream.prototype.getWebRtcPeer = function () { return this.wp; }; Stream.prototype.addEventListener = function (eventName, listener) { this.ee.addListener(eventName, listener); }; Stream.prototype.addOnceEventListener = function (eventName, listener) { this.ee.addOnceListener(eventName, listener); }; Stream.prototype.removeListener = function (eventName) { this.ee.removeAllListeners(eventName); }; Stream.prototype.showSpinner = function (spinnerParentId) { var progress = document.createElement('div'); progress.id = 'progress-' + this.getId(); progress.style.background = "center transparent url('img/spinner.gif') no-repeat"; var spinnerParent = document.getElementById(spinnerParentId); if (spinnerParent) { spinnerParent.appendChild(progress); } }; Stream.prototype.hideSpinner = function (spinnerId) { spinnerId = (spinnerId === undefined) ? this.getId() : spinnerId; hide('progress-' + spinnerId); }; Stream.prototype.playOnlyVideo = function (parentElement, thumbnailId) { // TO-DO: check somehow if the stream is audio only, so the element created is