|
@@ -28,6 +28,7 @@ function RemoteVideo(user, VideoLayout, emitter) {
|
28
|
28
|
this.emitter = emitter;
|
29
|
29
|
this.videoSpanId = `participant_${this.id}`;
|
30
|
30
|
SmallVideo.call(this, VideoLayout);
|
|
31
|
+ this._audioStreamElement = null;
|
31
|
32
|
this.hasRemoteVideoMenu = false;
|
32
|
33
|
this._supportsRemoteControl = false;
|
33
|
34
|
this.addRemoteVideoContainer();
|
|
@@ -200,6 +201,18 @@ RemoteVideo.prototype._generatePopupContent = function () {
|
200
|
201
|
popupmenuElement.appendChild(menuItem);
|
201
|
202
|
});
|
202
|
203
|
|
|
204
|
+ // feature check for volume setting as temasys objects cannot adjust volume
|
|
205
|
+ if (this._canSetAudioVolume()) {
|
|
206
|
+ const volumeScale = 100;
|
|
207
|
+ const volumeSlider = this._generatePopupMenuSliderItem({
|
|
208
|
+ handler: this._setAudioVolume.bind(this, volumeScale),
|
|
209
|
+ icon: 'icon-volume',
|
|
210
|
+ initialValue: this._getAudioElement().volume * volumeScale,
|
|
211
|
+ maxValue: volumeScale
|
|
212
|
+ });
|
|
213
|
+ popupmenuElement.appendChild(volumeSlider);
|
|
214
|
+ }
|
|
215
|
+
|
203
|
216
|
APP.translation.translateElement($(popupmenuElement));
|
204
|
217
|
|
205
|
218
|
return popupmenuElement;
|
|
@@ -343,6 +356,74 @@ RemoteVideo.prototype._generatePopupMenuItem = function (opts = {}) {
|
343
|
356
|
return menuItem;
|
344
|
357
|
};
|
345
|
358
|
|
|
359
|
+/**
|
|
360
|
+ * Create a div element with a slider.
|
|
361
|
+ *
|
|
362
|
+ * @param {object} options - Configuration for the div's display and slider.
|
|
363
|
+ * @param {string} options.icon - The classname for the icon to display.
|
|
364
|
+ * @param {int} options.maxValue - The maximum value on the slider. The default
|
|
365
|
+ * value is 100.
|
|
366
|
+ * @param {int} options.initialValue - The value the slider should start at.
|
|
367
|
+ * The default value is 0.
|
|
368
|
+ * @param {function} options.handler - The callback for slider value changes.
|
|
369
|
+ * @returns {Element} A div element with a slider.
|
|
370
|
+ */
|
|
371
|
+RemoteVideo.prototype._generatePopupMenuSliderItem = function (options) {
|
|
372
|
+ const template = `<div class='popupmenu__contents'>
|
|
373
|
+ <span class='popupmenu__icon'>
|
|
374
|
+ <i class=${options.icon}></i>
|
|
375
|
+ </span>
|
|
376
|
+ <input class='popupmenu__slider'
|
|
377
|
+ type='range'
|
|
378
|
+ min='0'
|
|
379
|
+ max=${options.maxValue || 100}
|
|
380
|
+ value=${options.initialValue || 0}>
|
|
381
|
+ </input>
|
|
382
|
+ </div>`;
|
|
383
|
+
|
|
384
|
+ const menuItem = document.createElement('li');
|
|
385
|
+ menuItem.className = 'popupmenu__item';
|
|
386
|
+ menuItem.innerHTML = template;
|
|
387
|
+
|
|
388
|
+ const slider = menuItem.getElementsByClassName('popupmenu__slider')[0];
|
|
389
|
+ slider.oninput = function () {
|
|
390
|
+ options.handler(Number(slider.value));
|
|
391
|
+ };
|
|
392
|
+
|
|
393
|
+ return menuItem;
|
|
394
|
+};
|
|
395
|
+
|
|
396
|
+/**
|
|
397
|
+ * Get the remote participant's audio element.
|
|
398
|
+ *
|
|
399
|
+ * @returns {Element} audio element
|
|
400
|
+ */
|
|
401
|
+RemoteVideo.prototype._getAudioElement = function () {
|
|
402
|
+ return this._audioStreamElement;
|
|
403
|
+};
|
|
404
|
+
|
|
405
|
+/**
|
|
406
|
+ * Check if the remote participant's audio can have its volume adjusted.
|
|
407
|
+ *
|
|
408
|
+ * @returns {boolean} true if the volume can be adjusted.
|
|
409
|
+ */
|
|
410
|
+RemoteVideo.prototype._canSetAudioVolume = function () {
|
|
411
|
+ const audioElement = this._getAudioElement();
|
|
412
|
+ return audioElement && audioElement.volume !== undefined;
|
|
413
|
+};
|
|
414
|
+
|
|
415
|
+/**
|
|
416
|
+ * Change the remote participant's volume level.
|
|
417
|
+ *
|
|
418
|
+ * @param {int} scale - The maximum value the slider can go to.
|
|
419
|
+ * @param {int} newVal - The value to set the slider to.
|
|
420
|
+ */
|
|
421
|
+RemoteVideo.prototype._setAudioVolume = function (scale, newVal) {
|
|
422
|
+ if (this._canSetAudioVolume()) {
|
|
423
|
+ this._getAudioElement().volume = newVal / scale;
|
|
424
|
+ }
|
|
425
|
+};
|
|
426
|
+
|
346
|
427
|
/**
|
347
|
428
|
* Updates the remote video menu.
|
348
|
429
|
*
|
|
@@ -613,6 +694,10 @@ RemoteVideo.prototype.addRemoteStreamElement = function (stream) {
|
613
|
694
|
}
|
614
|
695
|
|
615
|
696
|
$(streamElement).click(onClickHandler);
|
|
697
|
+
|
|
698
|
+ if (!isVideo) {
|
|
699
|
+ this._audioStreamElement = streamElement;
|
|
700
|
+ }
|
616
|
701
|
};
|
617
|
702
|
|
618
|
703
|
/**
|