Merge pull request #552 from damencho/shared-video-fixes
Shared video fixes
This commit is contained in:
commit
1e7cd06555
|
@ -402,6 +402,15 @@ export default {
|
||||||
listMembersIds () {
|
listMembersIds () {
|
||||||
return room.getParticipants().map(p => p.getId());
|
return room.getParticipants().map(p => p.getId());
|
||||||
},
|
},
|
||||||
|
/**
|
||||||
|
* Checks whether the participant identified by id is a moderator.
|
||||||
|
* @id id to search for participant
|
||||||
|
* @return {boolean} whether the participant is moderator
|
||||||
|
*/
|
||||||
|
isParticipantModerator (id) {
|
||||||
|
let user = room.getParticipantById(id);
|
||||||
|
return user && user.isModerator();
|
||||||
|
},
|
||||||
/**
|
/**
|
||||||
* Check if SIP is supported.
|
* Check if SIP is supported.
|
||||||
* @returns {boolean}
|
* @returns {boolean}
|
||||||
|
@ -737,7 +746,7 @@ export default {
|
||||||
console.log('USER %s LEFT', id, user);
|
console.log('USER %s LEFT', id, user);
|
||||||
APP.API.notifyUserLeft(id);
|
APP.API.notifyUserLeft(id);
|
||||||
APP.UI.removeUser(id, user.getDisplayName());
|
APP.UI.removeUser(id, user.getDisplayName());
|
||||||
APP.UI.stopSharedVideo({from: id});
|
APP.UI.stopSharedVideo(id);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
@ -1083,7 +1092,6 @@ export default {
|
||||||
room.sendCommandOnce(Commands.SHARED_VIDEO, {
|
room.sendCommandOnce(Commands.SHARED_VIDEO, {
|
||||||
value: url,
|
value: url,
|
||||||
attributes: {
|
attributes: {
|
||||||
from: APP.conference.localId,
|
|
||||||
state: state,
|
state: state,
|
||||||
time: time,
|
time: time,
|
||||||
volume: volume
|
volume: volume
|
||||||
|
@ -1096,7 +1104,6 @@ export default {
|
||||||
room.sendCommand(Commands.SHARED_VIDEO, {
|
room.sendCommand(Commands.SHARED_VIDEO, {
|
||||||
value: url,
|
value: url,
|
||||||
attributes: {
|
attributes: {
|
||||||
from: APP.conference.localId,
|
|
||||||
state: state,
|
state: state,
|
||||||
time: time,
|
time: time,
|
||||||
volume: volume
|
volume: volume
|
||||||
|
@ -1105,14 +1112,25 @@ export default {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
room.addCommandListener(
|
room.addCommandListener(
|
||||||
Commands.SHARED_VIDEO, ({value, attributes}) => {
|
Commands.SHARED_VIDEO, ({value, attributes}, id) => {
|
||||||
|
|
||||||
|
// if we are not the moderator or
|
||||||
|
// the command is coming from a user which is not the moderator
|
||||||
|
if (!(this.isLocalId(id) && room.isModerator())
|
||||||
|
&& !this.isParticipantModerator(id))
|
||||||
|
{
|
||||||
|
console.warn('Received shared video command ' +
|
||||||
|
'not from moderator');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (attributes.state === 'stop') {
|
if (attributes.state === 'stop') {
|
||||||
APP.UI.stopSharedVideo(attributes);
|
APP.UI.stopSharedVideo(id, attributes);
|
||||||
} else if (attributes.state === 'start') {
|
} else if (attributes.state === 'start') {
|
||||||
APP.UI.showSharedVideo(value, attributes);
|
APP.UI.showSharedVideo(id, value, attributes);
|
||||||
} else if (attributes.state === 'playing'
|
} else if (attributes.state === 'playing'
|
||||||
|| attributes.state === 'pause') {
|
|| attributes.state === 'pause') {
|
||||||
APP.UI.updateSharedVideo(value, attributes);
|
APP.UI.updateSharedVideo(id, value, attributes);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -270,7 +270,12 @@ class FollowMe {
|
||||||
if (this._conference.isLocalId(id))
|
if (this._conference.isLocalId(id))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// TODO Don't obey commands issued by non-moderators.
|
if (!this._conference.isParticipantModerator(id))
|
||||||
|
{
|
||||||
|
console.warn('Received follow-me command ' +
|
||||||
|
'not from moderator');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Applies the received/remote command to the user experience/interface
|
// Applies the received/remote command to the user experience/interface
|
||||||
// of the local participant.
|
// of the local participant.
|
||||||
|
|
|
@ -1107,32 +1107,35 @@ UI.updateDevicesAvailability = function (id, devices) {
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Show shared video.
|
* Show shared video.
|
||||||
* @param {string} url video url
|
* @param {string} id the id of the sender of the command
|
||||||
* @param {string} attributes
|
* @param {string} url video url
|
||||||
|
* @param {string} attributes
|
||||||
*/
|
*/
|
||||||
UI.showSharedVideo = function (url, attributes) {
|
UI.showSharedVideo = function (id, url, attributes) {
|
||||||
if (sharedVideoManager)
|
if (sharedVideoManager)
|
||||||
sharedVideoManager.showSharedVideo(url, attributes);
|
sharedVideoManager.showSharedVideo(id, url, attributes);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update shared video.
|
* Update shared video.
|
||||||
|
* @param {string} id the id of the sender of the command
|
||||||
* @param {string} url video url
|
* @param {string} url video url
|
||||||
* @param {string} attributes
|
* @param {string} attributes
|
||||||
*/
|
*/
|
||||||
UI.updateSharedVideo = function (url, attributes) {
|
UI.updateSharedVideo = function (id, url, attributes) {
|
||||||
if (sharedVideoManager)
|
if (sharedVideoManager)
|
||||||
sharedVideoManager.updateSharedVideo(url, attributes);
|
sharedVideoManager.updateSharedVideo(id, url, attributes);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Stop showing shared video.
|
* Stop showing shared video.
|
||||||
|
* @param {string} id the id of the sender of the command
|
||||||
* @param {string} attributes
|
* @param {string} attributes
|
||||||
*/
|
*/
|
||||||
UI.stopSharedVideo = function (attributes) {
|
UI.stopSharedVideo = function (id, attributes) {
|
||||||
if (sharedVideoManager)
|
if (sharedVideoManager)
|
||||||
sharedVideoManager.stopSharedVideo(attributes);
|
sharedVideoManager.stopSharedVideo(id, attributes);
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = UI;
|
module.exports = UI;
|
||||||
|
|
|
@ -50,10 +50,11 @@ export default class SharedVideoManager {
|
||||||
/**
|
/**
|
||||||
* Shows the player component and starts the checking function
|
* Shows the player component and starts the checking function
|
||||||
* that will be sending updates, if we are the one shared the video
|
* that will be sending updates, if we are the one shared the video
|
||||||
|
* @param id the id of the sender of the command
|
||||||
* @param url the video url
|
* @param url the video url
|
||||||
* @param attributes
|
* @param attributes
|
||||||
*/
|
*/
|
||||||
showSharedVideo (url, attributes) {
|
showSharedVideo (id, url, attributes) {
|
||||||
if (this.isSharedVideoShown)
|
if (this.isSharedVideoShown)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -61,7 +62,7 @@ export default class SharedVideoManager {
|
||||||
this.url = url;
|
this.url = url;
|
||||||
|
|
||||||
// the owner of the video
|
// the owner of the video
|
||||||
this.from = attributes.from;
|
this.from = id;
|
||||||
|
|
||||||
// This code loads the IFrame Player API code asynchronously.
|
// This code loads the IFrame Player API code asynchronously.
|
||||||
var tag = document.createElement('script');
|
var tag = document.createElement('script');
|
||||||
|
@ -184,10 +185,11 @@ export default class SharedVideoManager {
|
||||||
/**
|
/**
|
||||||
* Updates video, if its not playing and needs starting or
|
* Updates video, if its not playing and needs starting or
|
||||||
* if its playing and needs to be paysed
|
* if its playing and needs to be paysed
|
||||||
|
* @param id the id of the sender of the command
|
||||||
* @param url the video url
|
* @param url the video url
|
||||||
* @param attributes
|
* @param attributes
|
||||||
*/
|
*/
|
||||||
updateSharedVideo (url, attributes) {
|
updateSharedVideo (id, url, attributes) {
|
||||||
// if we are sending the event ignore
|
// if we are sending the event ignore
|
||||||
if(APP.conference.isLocalId(this.from)) {
|
if(APP.conference.isLocalId(this.from)) {
|
||||||
return;
|
return;
|
||||||
|
@ -196,7 +198,7 @@ export default class SharedVideoManager {
|
||||||
if (attributes.state == 'playing') {
|
if (attributes.state == 'playing') {
|
||||||
|
|
||||||
if(!this.isSharedVideoShown) {
|
if(!this.isSharedVideoShown) {
|
||||||
this.showSharedVideo(url, attributes);
|
this.showSharedVideo(id, url, attributes);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -239,22 +241,23 @@ export default class SharedVideoManager {
|
||||||
else {
|
else {
|
||||||
// if not shown show it, passing attributes so it can
|
// if not shown show it, passing attributes so it can
|
||||||
// be shown paused
|
// be shown paused
|
||||||
this.showSharedVideo(url, attributes);
|
this.showSharedVideo(id, url, attributes);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Stop shared video if it is currently showed. If the user started the
|
* Stop shared video if it is currently showed. If the user started the
|
||||||
* shared video is the one in the attributes.from (called when user
|
* shared video is the one in the id (called when user
|
||||||
* left and we want to remove video if the user sharing it left).
|
* left and we want to remove video if the user sharing it left).
|
||||||
|
* @param id the id of the sender of the command
|
||||||
* @param attributes
|
* @param attributes
|
||||||
*/
|
*/
|
||||||
stopSharedVideo (attributes) {
|
stopSharedVideo (id, attributes) {
|
||||||
if (!this.isSharedVideoShown)
|
if (!this.isSharedVideoShown)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if(this.from !== attributes.from)
|
if(this.from !== id)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if(this.intervalId) {
|
if(this.intervalId) {
|
||||||
|
|
|
@ -922,7 +922,8 @@ var VideoLayout = {
|
||||||
let currentId = largeVideo.id;
|
let currentId = largeVideo.id;
|
||||||
|
|
||||||
if (!isOnLarge || forceUpdate) {
|
if (!isOnLarge || forceUpdate) {
|
||||||
if (id !== currentId) {
|
let videoType = this.getRemoteVideoType(id);
|
||||||
|
if (id !== currentId && videoType === VIDEO_CONTAINER_TYPE) {
|
||||||
eventEmitter.emit(UIEvents.SELECTED_ENDPOINT, id);
|
eventEmitter.emit(UIEvents.SELECTED_ENDPOINT, id);
|
||||||
}
|
}
|
||||||
if (currentId) {
|
if (currentId) {
|
||||||
|
@ -931,7 +932,6 @@ var VideoLayout = {
|
||||||
|
|
||||||
let smallVideo = this.getSmallVideo(id);
|
let smallVideo = this.getSmallVideo(id);
|
||||||
|
|
||||||
let videoType = this.getRemoteVideoType(id);
|
|
||||||
largeVideo.updateLargeVideo(
|
largeVideo.updateLargeVideo(
|
||||||
id,
|
id,
|
||||||
smallVideo.videoStream,
|
smallVideo.videoStream,
|
||||||
|
|
Loading…
Reference in New Issue