|
|
|
@ -30,7 +30,7 @@ import { |
|
|
|
|
SHARED_VIDEO, |
|
|
|
|
VIDEO_PLAYER_PARTICIPANT_NAME |
|
|
|
|
} from './constants'; |
|
|
|
|
import { isSharedVideoEnabled, isSharingStatus, isURLAllowedForSharedVideo } from './functions'; |
|
|
|
|
import { isSharedVideoEnabled, isSharingStatus, isURLAllowedForSharedVideo, sendShareVideoCommand } from './functions'; |
|
|
|
|
import logger from './logger'; |
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -155,6 +155,14 @@ MiddlewareRegistry.register(store => next => action => { |
|
|
|
|
APP.API.notifyAudioOrVideoSharingToggled(MEDIA_TYPE.VIDEO, status, ownerId); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// when setting status we need to send the command for that, but not do it for the start command
|
|
|
|
|
// as we are sending the command in playSharedVideo and setting the start status once
|
|
|
|
|
// we receive the response, this way we will start the video at the same time when remote participants
|
|
|
|
|
// start it, on receiving the command
|
|
|
|
|
if (status === 'start') { |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (localParticipantId === ownerId) { |
|
|
|
|
sendShareVideoCommand({ |
|
|
|
|
conference, |
|
|
|
@ -224,12 +232,15 @@ function handleSharingVideoStatus(store: IStore, videoUrl: string, |
|
|
|
|
|
|
|
|
|
if (oldVideoUrl && oldVideoUrl !== videoUrl) { |
|
|
|
|
logger.warn( |
|
|
|
|
`User with id: ${localParticipantId} sent videoUrl: ${videoUrl} while we are playing: ${oldVideoUrl}`); |
|
|
|
|
`User with id: ${from} sent videoUrl: ${videoUrl} while we are playing: ${oldVideoUrl}`); |
|
|
|
|
|
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (state === PLAYBACK_START && !isSharingStatus(oldStatus)) { |
|
|
|
|
// If the video was not started (no participant) we want to create the participant
|
|
|
|
|
// this can be triggered by start, but also by paused or playing
|
|
|
|
|
// commands (joining late) and getting the current state
|
|
|
|
|
if (state === PLAYBACK_START || !isSharingStatus(oldStatus)) { |
|
|
|
|
const youtubeId = videoUrl.match(/http/) ? false : videoUrl; |
|
|
|
|
const avatarURL = youtubeId ? `https://img.youtube.com/vi/${youtubeId}/0.jpg` : ''; |
|
|
|
|
|
|
|
|
@ -242,6 +253,15 @@ function handleSharingVideoStatus(store: IStore, videoUrl: string, |
|
|
|
|
})); |
|
|
|
|
|
|
|
|
|
dispatch(pinParticipant(videoUrl)); |
|
|
|
|
|
|
|
|
|
if (localParticipantId === from) { |
|
|
|
|
dispatch(setSharedVideoStatus({ |
|
|
|
|
videoUrl, |
|
|
|
|
status: state, |
|
|
|
|
time: Number(time), |
|
|
|
|
ownerId: localParticipantId |
|
|
|
|
})); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (localParticipantId !== from) { |
|
|
|
@ -254,31 +274,3 @@ function handleSharingVideoStatus(store: IStore, videoUrl: string, |
|
|
|
|
})); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/* eslint-disable max-params */ |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Sends SHARED_VIDEO command. |
|
|
|
|
* |
|
|
|
|
* @param {string} id - The id of the video. |
|
|
|
|
* @param {string} status - The status of the shared video. |
|
|
|
|
* @param {JitsiConference} conference - The current conference. |
|
|
|
|
* @param {string} localParticipantId - The id of the local participant. |
|
|
|
|
* @param {string} time - The seek position of the video. |
|
|
|
|
* @returns {void} |
|
|
|
|
*/ |
|
|
|
|
function sendShareVideoCommand({ id, status, conference, localParticipantId = '', time, muted, volume }: { |
|
|
|
|
conference?: IJitsiConference; id: string; localParticipantId?: string; muted: boolean; |
|
|
|
|
status: string; time: number; volume: number; |
|
|
|
|
}) { |
|
|
|
|
conference?.sendCommandOnce(SHARED_VIDEO, { |
|
|
|
|
value: id, |
|
|
|
|
attributes: { |
|
|
|
|
from: localParticipantId, |
|
|
|
|
muted, |
|
|
|
|
state: status, |
|
|
|
|
time, |
|
|
|
|
volume |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|