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

80 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 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('bbb_enable_screen_sharing', 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('bbb_enable_video', KURENTO_CONFIG.enableVideo);
2016-09-15 04:25:31 +08:00
}
2018-04-10 02:48:21 +08:00
const swapLayout = {
value: getFromUserSettings('bbb_auto_swap_layout', LAYOUT_CONFIG.autoSwapLayout),
2018-04-10 02:48:21 +08:00
tracker: new Tracker.Dependency(),
};
const setSwapLayout = () => {
swapLayout.value = getFromUserSettings('bbb_auto_swap_layout', 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,
};