From 2c70388a9e2c584e40d6589dbcfc8229635e54d1 Mon Sep 17 00:00:00 2001 From: Jip-Hop Date: Fri, 23 Aug 2019 17:35:10 +0200 Subject: [PATCH] Get participant specific video element * Get participant specific video element We now have the ability to select the video element for specific participants. I'm tweaking the jitsi-meet-electron app for my use case. I need to open Always On Top windows for specific participants, so the current _getLargeVideo() wont suffice. I made a post about this in the Developers section on the Jitsi Community Forum, but it got blocked by Akismet. * Add dots at end of sentence. * Fixed ESlint errors and add additional check for iframe. * Use _myUserID instead of string. * Return the local video by default if participantId is undefined. * Fixed mistake in string template. --- modules/API/external/external_api.js | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/modules/API/external/external_api.js b/modules/API/external/external_api.js index 0a4aa9eac..a089d27ae 100644 --- a/modules/API/external/external_api.js +++ b/modules/API/external/external_api.js @@ -366,6 +366,30 @@ export default class JitsiMeetExternalAPI extends EventEmitter { return iframe.contentWindow.document.getElementById('largeVideo'); } + /** + * Getter for participant specific video element in Jitsi Meet. + * + * @param {string|undefined} participantId - Id of participant to return the video for. + * + * @returns {HTMLElement|undefined} - The requested video. Will return the local video + * by default if participantId is undefined. + */ + _getParticipantVideo(participantId) { + const iframe = this.getIFrame(); + + if (!iframe + || !iframe.contentWindow + || !iframe.contentWindow.document) { + return; + } + + if (typeof participantId === 'undefined' || participantId === this._myUserID) { + return iframe.contentWindow.document.getElementById('localVideo_container'); + } + + return iframe.contentWindow.document.querySelector(`#participant_${participantId} video`); + } + /** * Sets the size of the iframe element. *