|
@@ -30,7 +30,7 @@ import {
|
30
|
30
|
SHARED_VIDEO,
|
31
|
31
|
VIDEO_PLAYER_PARTICIPANT_NAME
|
32
|
32
|
} from './constants';
|
33
|
|
-import { isSharedVideoEnabled, isSharingStatus, isURLAllowedForSharedVideo } from './functions';
|
|
33
|
+import { isSharedVideoEnabled, isSharingStatus, isURLAllowedForSharedVideo, sendShareVideoCommand } from './functions';
|
34
|
34
|
import logger from './logger';
|
35
|
35
|
|
36
|
36
|
|
|
@@ -155,6 +155,14 @@ MiddlewareRegistry.register(store => next => action => {
|
155
|
155
|
APP.API.notifyAudioOrVideoSharingToggled(MEDIA_TYPE.VIDEO, status, ownerId);
|
156
|
156
|
}
|
157
|
157
|
|
|
158
|
+ // when setting status we need to send the command for that, but not do it for the start command
|
|
159
|
+ // as we are sending the command in playSharedVideo and setting the start status once
|
|
160
|
+ // we receive the response, this way we will start the video at the same time when remote participants
|
|
161
|
+ // start it, on receiving the command
|
|
162
|
+ if (status === 'start') {
|
|
163
|
+ break;
|
|
164
|
+ }
|
|
165
|
+
|
158
|
166
|
if (localParticipantId === ownerId) {
|
159
|
167
|
sendShareVideoCommand({
|
160
|
168
|
conference,
|
|
@@ -224,12 +232,15 @@ function handleSharingVideoStatus(store: IStore, videoUrl: string,
|
224
|
232
|
|
225
|
233
|
if (oldVideoUrl && oldVideoUrl !== videoUrl) {
|
226
|
234
|
logger.warn(
|
227
|
|
- `User with id: ${localParticipantId} sent videoUrl: ${videoUrl} while we are playing: ${oldVideoUrl}`);
|
|
235
|
+ `User with id: ${from} sent videoUrl: ${videoUrl} while we are playing: ${oldVideoUrl}`);
|
228
|
236
|
|
229
|
237
|
return;
|
230
|
238
|
}
|
231
|
239
|
|
232
|
|
- if (state === PLAYBACK_START && !isSharingStatus(oldStatus)) {
|
|
240
|
+ // If the video was not started (no participant) we want to create the participant
|
|
241
|
+ // this can be triggered by start, but also by paused or playing
|
|
242
|
+ // commands (joining late) and getting the current state
|
|
243
|
+ if (state === PLAYBACK_START || !isSharingStatus(oldStatus)) {
|
233
|
244
|
const youtubeId = videoUrl.match(/http/) ? false : videoUrl;
|
234
|
245
|
const avatarURL = youtubeId ? `https://img.youtube.com/vi/${youtubeId}/0.jpg` : '';
|
235
|
246
|
|
|
@@ -242,6 +253,15 @@ function handleSharingVideoStatus(store: IStore, videoUrl: string,
|
242
|
253
|
}));
|
243
|
254
|
|
244
|
255
|
dispatch(pinParticipant(videoUrl));
|
|
256
|
+
|
|
257
|
+ if (localParticipantId === from) {
|
|
258
|
+ dispatch(setSharedVideoStatus({
|
|
259
|
+ videoUrl,
|
|
260
|
+ status: state,
|
|
261
|
+ time: Number(time),
|
|
262
|
+ ownerId: localParticipantId
|
|
263
|
+ }));
|
|
264
|
+ }
|
245
|
265
|
}
|
246
|
266
|
|
247
|
267
|
if (localParticipantId !== from) {
|
|
@@ -254,31 +274,3 @@ function handleSharingVideoStatus(store: IStore, videoUrl: string,
|
254
|
274
|
}));
|
255
|
275
|
}
|
256
|
276
|
}
|
257
|
|
-
|
258
|
|
-/* eslint-disable max-params */
|
259
|
|
-
|
260
|
|
-/**
|
261
|
|
- * Sends SHARED_VIDEO command.
|
262
|
|
- *
|
263
|
|
- * @param {string} id - The id of the video.
|
264
|
|
- * @param {string} status - The status of the shared video.
|
265
|
|
- * @param {JitsiConference} conference - The current conference.
|
266
|
|
- * @param {string} localParticipantId - The id of the local participant.
|
267
|
|
- * @param {string} time - The seek position of the video.
|
268
|
|
- * @returns {void}
|
269
|
|
- */
|
270
|
|
-function sendShareVideoCommand({ id, status, conference, localParticipantId = '', time, muted, volume }: {
|
271
|
|
- conference?: IJitsiConference; id: string; localParticipantId?: string; muted: boolean;
|
272
|
|
- status: string; time: number; volume: number;
|
273
|
|
-}) {
|
274
|
|
- conference?.sendCommandOnce(SHARED_VIDEO, {
|
275
|
|
- value: id,
|
276
|
|
- attributes: {
|
277
|
|
- from: localParticipantId,
|
278
|
|
- muted,
|
279
|
|
- state: status,
|
280
|
|
- time,
|
281
|
|
- volume
|
282
|
|
- }
|
283
|
|
- });
|
284
|
|
-}
|