bigbluebutton-Github/bigbluebutton-html5/imports/ui/components/media/service.js

81 lines
2.4 KiB
JavaScript
Raw Normal View History

import Presentations from '/imports/api/presentations';
import { isVideoBroadcasting } from '/imports/ui/components/screenshare/service';
2019-07-13 04:08:55 +08:00
import { getVideoUrl } from '/imports/ui/components/external-video-player/service';
import Auth from '/imports/ui/services/auth';
import Users from '/imports/api/users';
import Settings from '/imports/ui/services/settings';
import VideoService from '/imports/ui/components/video-provider/service';
import PollingService from '/imports/ui/components/polling/service';
import getFromUserSettings from '/imports/ui/services/users-settings';
const LAYOUT_CONFIG = Meteor.settings.public.layout;
const KURENTO_CONFIG = Meteor.settings.public.kurento;
2017-06-03 03:25:02 +08:00
const getPresentationInfo = () => {
2017-07-01 03:16:00 +08:00
const currentPresentation = Presentations.findOne({
2017-07-25 02:46:53 +08:00
current: true,
2017-06-03 03:25:02 +08:00
});
return {
2017-06-03 03:25:02 +08:00
current_presentation: (currentPresentation != null),
};
};
const isUserPresenter = () => Users.findOne({ userId: Auth.userID },
{ fields: { presenter: 1 } }).presenter;
2016-09-15 04:25:31 +08:00
function shouldShowWhiteboard() {
return true;
}
function shouldShowScreenshare() {
const { viewScreenshare } = Settings.dataSaving;
const enableScreensharing = getFromUserSettings('enableScreensharing', KURENTO_CONFIG.enableScreensharing);
return enableScreensharing && viewScreenshare && isVideoBroadcasting();
2016-09-15 04:25:31 +08:00
}
function shouldShowExternalVideo() {
const { enabled: enableExternalVideo } = Meteor.settings.public.externalVideoPlayer;
2019-07-13 04:08:55 +08:00
return enableExternalVideo && getVideoUrl();
}
2016-09-15 04:25:31 +08:00
function shouldShowOverlay() {
return getFromUserSettings('enableVideo', KURENTO_CONFIG.enableVideo);
2016-09-15 04:25:31 +08:00
}
2018-04-10 02:48:21 +08:00
const swapLayout = {
value: getFromUserSettings('autoSwapLayout', LAYOUT_CONFIG.autoSwapLayout),
2018-04-10 02:48:21 +08:00
tracker: new Tracker.Dependency(),
};
const setSwapLayout = () => {
swapLayout.value = getFromUserSettings('autoSwapLayout', LAYOUT_CONFIG.autoSwapLayout);
swapLayout.tracker.changed();
};
2018-04-10 02:48:21 +08:00
const toggleSwapLayout = () => {
swapLayout.value = !swapLayout.value;
swapLayout.tracker.changed();
};
export const shouldEnableSwapLayout = () => !shouldShowScreenshare() && !shouldShowExternalVideo();
2018-04-10 02:48:21 +08:00
export const getSwapLayout = () => {
swapLayout.tracker.depend();
return swapLayout.value;
2018-04-10 02:48:21 +08:00
};
export default {
getPresentationInfo,
2016-09-15 04:25:31 +08:00
shouldShowWhiteboard,
shouldShowScreenshare,
shouldShowExternalVideo,
2016-09-15 04:25:31 +08:00
shouldShowOverlay,
isUserPresenter,
isVideoBroadcasting,
2018-04-10 02:48:21 +08:00
toggleSwapLayout,
shouldEnableSwapLayout,
getSwapLayout,
setSwapLayout,
};