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

94 lines
2.6 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 Settings from '/imports/ui/services/settings';
import getFromUserSettings from '/imports/ui/services/users-settings';
import { isExternalVideoEnabled, isScreenSharingEnabled } from '/imports/ui/services/features';
import { ACTIONS } from '../layout/enums';
const LAYOUT_CONFIG = Meteor.settings.public.layout;
const KURENTO_CONFIG = Meteor.settings.public.kurento;
const PRESENTATION_CONFIG = Meteor.settings.public.presentation;
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),
};
};
2016-09-15 04:25:31 +08:00
function shouldShowWhiteboard() {
return true;
}
function shouldShowScreenshare() {
const { viewScreenshare } = Settings.dataSaving;
2022-02-07 21:22:52 +08:00
return isScreenSharingEnabled() && viewScreenshare && isVideoBroadcasting();
2016-09-15 04:25:31 +08:00
}
function shouldShowExternalVideo() {
return isExternalVideoEnabled() && 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(),
};
2021-09-03 02:29:35 +08:00
const setSwapLayout = (layoutContextDispatch) => {
2021-09-28 03:57:02 +08:00
const hidePresentation = getFromUserSettings('bbb_hide_presentation', LAYOUT_CONFIG.hidePresentation);
swapLayout.value = getFromUserSettings('bbb_auto_swap_layout', LAYOUT_CONFIG.autoSwapLayout) || hidePresentation;
swapLayout.tracker.changed();
2021-09-03 02:29:35 +08:00
2021-09-28 03:57:02 +08:00
if (!hidePresentation) {
layoutContextDispatch({
type: ACTIONS.SET_PRESENTATION_IS_OPEN,
value: !swapLayout.value,
});
}
};
2021-08-05 19:03:24 +08:00
const toggleSwapLayout = (layoutContextDispatch) => {
window.dispatchEvent(new Event('togglePresentationHide'));
2018-04-10 02:48:21 +08:00
swapLayout.value = !swapLayout.value;
swapLayout.tracker.changed();
2021-08-05 19:03:24 +08:00
layoutContextDispatch({
type: ACTIONS.SET_PRESENTATION_IS_OPEN,
value: !swapLayout.value,
});
2018-04-10 02:48:21 +08:00
};
export const shouldEnableSwapLayout = () => {
if (!PRESENTATION_CONFIG.oldMinimizeButton) {
return true;
}
return !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,
isVideoBroadcasting,
2018-04-10 02:48:21 +08:00
toggleSwapLayout,
shouldEnableSwapLayout,
getSwapLayout,
setSwapLayout,
};