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

52 lines
1.2 KiB
JavaScript
Raw Normal View History

import Meetings from '/imports/api/meetings';
import Auth from '/imports/ui/services/auth';
import ExternalVideoStreamer from '/imports/api/external-videos';
import { makeCall } from '/imports/ui/services/api';
import ReactPlayer from 'react-player';
const isUrlValid = url => ReactPlayer.canPlay(url);
const startWatching = (url) => {
2019-07-13 04:08:55 +08:00
const externalVideoUrl = url;
makeCall('startWatchingExternalVideo', { externalVideoUrl });
};
const stopWatching = () => {
makeCall('stopWatchingExternalVideo');
};
const sendMessage = (event, data) => {
ExternalVideoStreamer.emit(event, {
...data,
2019-01-21 13:49:01 +08:00
meetingId: Auth.meetingID,
userId: Auth.userID,
});
};
const onMessage = (message, func) => {
ExternalVideoStreamer.on(message, func);
};
const removeAllListeners = (eventType) => {
ExternalVideoStreamer.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,
};