bigbluebutton-Github/bigbluebutton-html5/imports/ui/components/external-video-player/service.js

75 lines
1.7 KiB
JavaScript
Raw Normal View History

import Meetings from '/imports/api/meetings';
import Auth from '/imports/ui/services/auth';
import { getStreamer } from '/imports/api/external-videos';
import { makeCall } from '/imports/ui/services/api';
import ReactPlayer from 'react-player';
import Panopto from './custom-players/panopto';
const isUrlValid = (url) => {
return /^https.*$/.test(url) && (ReactPlayer.canPlay(url) || Panopto.canPlay(url));
}
const startWatching = (url) => {
let externalVideoUrl = url;
if (Panopto.canPlay(url)) {
externalVideoUrl = Panopto.getSocialUrl(url);
}
makeCall('startWatchingExternalVideo', { externalVideoUrl });
};
const stopWatching = () => {
makeCall('stopWatchingExternalVideo');
};
Committer: Antonio Guirado <amguirado73@gmail.com> Changes to be committed: new file: akka-bbb-apps/src/main/scala/org/bigbluebutton/core/apps/externalvideo/ExternalVideoApp2x.scala new file: akka-bbb-apps/src/main/scala/org/bigbluebutton/core/apps/externalvideo/StartExternalVideoPubMsgHdlr.scala new file: akka-bbb-apps/src/main/scala/org/bigbluebutton/core/apps/externalvideo/StopExternalVideoPubMsgHdlr.scala new file: akka-bbb-apps/src/main/scala/org/bigbluebutton/core/apps/externalvideo/UpdateExternalVideoPubMsgHdlr.scala modified: akka-bbb-apps/src/main/scala/org/bigbluebutton/core/pubsub/senders/ReceivedJsonMsgHandlerActor.scala modified: akka-bbb-apps/src/main/scala/org/bigbluebutton/core/running/MeetingActor.scala modified: akka-bbb-apps/src/main/scala/org/bigbluebutton/core2/FromAkkaAppsMsgSenderActor.scala new file: bbb-common-message/src/main/scala/org/bigbluebutton/common2/msgs/ExternalVideoMsgs.scala new file: bigbluebutton-html5/imports/api/external-videos/server/eventHandlers.js new file: bigbluebutton-html5/imports/api/external-videos/server/handlers/startExternalVideo.js new file: bigbluebutton-html5/imports/api/external-videos/server/handlers/stopExternalVideo.js new file: bigbluebutton-html5/imports/api/external-videos/server/handlers/updateExternalVideo.js modified: bigbluebutton-html5/imports/api/external-videos/server/index.js modified: bigbluebutton-html5/imports/api/external-videos/server/methods.js modified: bigbluebutton-html5/imports/api/external-videos/server/methods/emitExternalVideoEvent.js modified: bigbluebutton-html5/imports/api/external-videos/server/methods/startWatchingExternalVideo.js modified: bigbluebutton-html5/imports/api/external-videos/server/methods/stopWatchingExternalVideo.js new file: bigbluebutton-html5/imports/api/external-videos/server/streamer.js modified: bigbluebutton-html5/imports/api/meetings/server/handlers/meetingDestruction.js modified: bigbluebutton-html5/imports/api/meetings/server/modifiers/addMeeting.js modified: bigbluebutton-html5/imports/api/meetings/server/modifiers/meetingHasEnded.js modified: bigbluebutton-html5/imports/api/users/server/handlers/validateAuthToken.js modified: bigbluebutton-html5/imports/api/users/server/store/bannedUsers.js modified: bigbluebutton-html5/imports/startup/server/index.js modified: bigbluebutton-html5/imports/startup/server/redis.js modified: bigbluebutton-html5/imports/ui/components/external-video-player/service.js modified: bigbluebutton-html5/private/config/settings.yml
2020-08-28 18:58:55 +08:00
let lastMessage = null;
const sendMessage = (event, data) => {
Committer: Antonio Guirado <amguirado73@gmail.com> Changes to be committed: new file: akka-bbb-apps/src/main/scala/org/bigbluebutton/core/apps/externalvideo/ExternalVideoApp2x.scala new file: akka-bbb-apps/src/main/scala/org/bigbluebutton/core/apps/externalvideo/StartExternalVideoPubMsgHdlr.scala new file: akka-bbb-apps/src/main/scala/org/bigbluebutton/core/apps/externalvideo/StopExternalVideoPubMsgHdlr.scala new file: akka-bbb-apps/src/main/scala/org/bigbluebutton/core/apps/externalvideo/UpdateExternalVideoPubMsgHdlr.scala modified: akka-bbb-apps/src/main/scala/org/bigbluebutton/core/pubsub/senders/ReceivedJsonMsgHandlerActor.scala modified: akka-bbb-apps/src/main/scala/org/bigbluebutton/core/running/MeetingActor.scala modified: akka-bbb-apps/src/main/scala/org/bigbluebutton/core2/FromAkkaAppsMsgSenderActor.scala new file: bbb-common-message/src/main/scala/org/bigbluebutton/common2/msgs/ExternalVideoMsgs.scala new file: bigbluebutton-html5/imports/api/external-videos/server/eventHandlers.js new file: bigbluebutton-html5/imports/api/external-videos/server/handlers/startExternalVideo.js new file: bigbluebutton-html5/imports/api/external-videos/server/handlers/stopExternalVideo.js new file: bigbluebutton-html5/imports/api/external-videos/server/handlers/updateExternalVideo.js modified: bigbluebutton-html5/imports/api/external-videos/server/index.js modified: bigbluebutton-html5/imports/api/external-videos/server/methods.js modified: bigbluebutton-html5/imports/api/external-videos/server/methods/emitExternalVideoEvent.js modified: bigbluebutton-html5/imports/api/external-videos/server/methods/startWatchingExternalVideo.js modified: bigbluebutton-html5/imports/api/external-videos/server/methods/stopWatchingExternalVideo.js new file: bigbluebutton-html5/imports/api/external-videos/server/streamer.js modified: bigbluebutton-html5/imports/api/meetings/server/handlers/meetingDestruction.js modified: bigbluebutton-html5/imports/api/meetings/server/modifiers/addMeeting.js modified: bigbluebutton-html5/imports/api/meetings/server/modifiers/meetingHasEnded.js modified: bigbluebutton-html5/imports/api/users/server/handlers/validateAuthToken.js modified: bigbluebutton-html5/imports/api/users/server/store/bannedUsers.js modified: bigbluebutton-html5/imports/startup/server/index.js modified: bigbluebutton-html5/imports/startup/server/redis.js modified: bigbluebutton-html5/imports/ui/components/external-video-player/service.js modified: bigbluebutton-html5/private/config/settings.yml
2020-08-28 18:58:55 +08:00
// don't re-send repeated update messages
if (lastMessage && lastMessage.event === event
&& event === 'playerUpdate' && lastMessage.time === data.time) {
return;
}
Committer: Antonio Guirado <amguirado73@gmail.com> Changes to be committed: new file: akka-bbb-apps/src/main/scala/org/bigbluebutton/core/apps/externalvideo/ExternalVideoApp2x.scala new file: akka-bbb-apps/src/main/scala/org/bigbluebutton/core/apps/externalvideo/StartExternalVideoPubMsgHdlr.scala new file: akka-bbb-apps/src/main/scala/org/bigbluebutton/core/apps/externalvideo/StopExternalVideoPubMsgHdlr.scala new file: akka-bbb-apps/src/main/scala/org/bigbluebutton/core/apps/externalvideo/UpdateExternalVideoPubMsgHdlr.scala modified: akka-bbb-apps/src/main/scala/org/bigbluebutton/core/pubsub/senders/ReceivedJsonMsgHandlerActor.scala modified: akka-bbb-apps/src/main/scala/org/bigbluebutton/core/running/MeetingActor.scala modified: akka-bbb-apps/src/main/scala/org/bigbluebutton/core2/FromAkkaAppsMsgSenderActor.scala new file: bbb-common-message/src/main/scala/org/bigbluebutton/common2/msgs/ExternalVideoMsgs.scala new file: bigbluebutton-html5/imports/api/external-videos/server/eventHandlers.js new file: bigbluebutton-html5/imports/api/external-videos/server/handlers/startExternalVideo.js new file: bigbluebutton-html5/imports/api/external-videos/server/handlers/stopExternalVideo.js new file: bigbluebutton-html5/imports/api/external-videos/server/handlers/updateExternalVideo.js modified: bigbluebutton-html5/imports/api/external-videos/server/index.js modified: bigbluebutton-html5/imports/api/external-videos/server/methods.js modified: bigbluebutton-html5/imports/api/external-videos/server/methods/emitExternalVideoEvent.js modified: bigbluebutton-html5/imports/api/external-videos/server/methods/startWatchingExternalVideo.js modified: bigbluebutton-html5/imports/api/external-videos/server/methods/stopWatchingExternalVideo.js new file: bigbluebutton-html5/imports/api/external-videos/server/streamer.js modified: bigbluebutton-html5/imports/api/meetings/server/handlers/meetingDestruction.js modified: bigbluebutton-html5/imports/api/meetings/server/modifiers/addMeeting.js modified: bigbluebutton-html5/imports/api/meetings/server/modifiers/meetingHasEnded.js modified: bigbluebutton-html5/imports/api/users/server/handlers/validateAuthToken.js modified: bigbluebutton-html5/imports/api/users/server/store/bannedUsers.js modified: bigbluebutton-html5/imports/startup/server/index.js modified: bigbluebutton-html5/imports/startup/server/redis.js modified: bigbluebutton-html5/imports/ui/components/external-video-player/service.js modified: bigbluebutton-html5/private/config/settings.yml
2020-08-28 18:58:55 +08:00
// don't register to redis a viewer joined message
Committer: Antonio Guirado <amguirado73@gmail.com> Changes to be committed: new file: akka-bbb-apps/src/main/scala/org/bigbluebutton/core/apps/externalvideo/ExternalVideoApp2x.scala new file: akka-bbb-apps/src/main/scala/org/bigbluebutton/core/apps/externalvideo/StartExternalVideoPubMsgHdlr.scala new file: akka-bbb-apps/src/main/scala/org/bigbluebutton/core/apps/externalvideo/StopExternalVideoPubMsgHdlr.scala new file: akka-bbb-apps/src/main/scala/org/bigbluebutton/core/apps/externalvideo/UpdateExternalVideoPubMsgHdlr.scala modified: akka-bbb-apps/src/main/scala/org/bigbluebutton/core/pubsub/senders/ReceivedJsonMsgHandlerActor.scala modified: akka-bbb-apps/src/main/scala/org/bigbluebutton/core/running/MeetingActor.scala modified: akka-bbb-apps/src/main/scala/org/bigbluebutton/core2/FromAkkaAppsMsgSenderActor.scala new file: bbb-common-message/src/main/scala/org/bigbluebutton/common2/msgs/ExternalVideoMsgs.scala new file: bigbluebutton-html5/imports/api/external-videos/server/eventHandlers.js new file: bigbluebutton-html5/imports/api/external-videos/server/handlers/startExternalVideo.js new file: bigbluebutton-html5/imports/api/external-videos/server/handlers/stopExternalVideo.js new file: bigbluebutton-html5/imports/api/external-videos/server/handlers/updateExternalVideo.js modified: bigbluebutton-html5/imports/api/external-videos/server/index.js modified: bigbluebutton-html5/imports/api/external-videos/server/methods.js modified: bigbluebutton-html5/imports/api/external-videos/server/methods/emitExternalVideoEvent.js modified: bigbluebutton-html5/imports/api/external-videos/server/methods/startWatchingExternalVideo.js modified: bigbluebutton-html5/imports/api/external-videos/server/methods/stopWatchingExternalVideo.js new file: bigbluebutton-html5/imports/api/external-videos/server/streamer.js modified: bigbluebutton-html5/imports/api/meetings/server/handlers/meetingDestruction.js modified: bigbluebutton-html5/imports/api/meetings/server/modifiers/addMeeting.js modified: bigbluebutton-html5/imports/api/meetings/server/modifiers/meetingHasEnded.js modified: bigbluebutton-html5/imports/api/users/server/handlers/validateAuthToken.js modified: bigbluebutton-html5/imports/api/users/server/store/bannedUsers.js modified: bigbluebutton-html5/imports/startup/server/index.js modified: bigbluebutton-html5/imports/startup/server/redis.js modified: bigbluebutton-html5/imports/ui/components/external-video-player/service.js modified: bigbluebutton-html5/private/config/settings.yml
2020-08-28 18:58:55 +08:00
if (event === 'viewerJoined') {
return;
}
lastMessage = { ...data, event };
makeCall('emitExternalVideoEvent', { status: event, playerStatus: data });
};
const onMessage = (message, func) => {
const streamer = getStreamer(Auth.meetingID);
streamer.on(message, func);
};
const removeAllListeners = (eventType) => {
const streamer = getStreamer(Auth.meetingID);
streamer.removeAllListeners(eventType);
};
2019-07-13 04:08:55 +08:00
const getVideoUrl = () => {
2019-01-21 13:49:01 +08:00
const meetingId = Auth.meetingID;
2019-09-11 02:04:42 +08:00
const meeting = Meetings.findOne({ meetingId }, { fields: { externalVideoUrl: 1 } });
return meeting && meeting.externalVideoUrl;
};
export {
sendMessage,
onMessage,
removeAllListeners,
2019-07-13 04:08:55 +08:00
getVideoUrl,
isUrlValid,
startWatching,
stopWatching,
};