bigbluebutton-Github/bigbluebutton-html5/imports/ui/components/audio/audio-controls/container.jsx

48 lines
2.1 KiB
React
Raw Normal View History

import React from 'react';
import { withTracker } from 'meteor/react-meteor-data';
import { withModalMounter } from '/imports/ui/components/modal/service';
import AudioManager from '/imports/ui/services/audio-manager';
import { makeCall } from '/imports/ui/services/api';
2019-05-24 00:47:56 +08:00
import lockContextContainer from '/imports/ui/components/lock-viewers/context/container';
import AudioControls from './component';
2017-09-29 21:38:10 +08:00
import AudioModalContainer from '../audio-modal/container';
import Service from '../service';
const AudioControlsContainer = props => <AudioControls {...props} />;
const processToggleMuteFromOutside = (e) => {
switch (e.data) {
case 'c_mute': {
makeCall('toggleSelfVoice');
break;
}
case 'get_audio_joined_status': {
const audioJoinedState = AudioManager.isConnected ? 'joinedAudio' : 'notInAudio';
this.window.parent.postMessage({ response: audioJoinedState }, '*');
break;
}
case 'c_mute_status': {
const muteState = AudioManager.isMuted ? 'selfMuted' : 'selfUnmuted';
this.window.parent.postMessage({ response: muteState }, '*');
break;
}
default: {
// console.log(e.data);
}
}
};
2019-05-24 00:47:56 +08:00
export default lockContextContainer(withModalMounter(withTracker(({ mountModal, userLocks }) => ({
processToggleMuteFromOutside: arg => processToggleMuteFromOutside(arg),
2019-05-24 00:47:56 +08:00
showMute: Service.isConnected() && !Service.isListenOnly() && !Service.isEchoTest() && !userLocks.userMic,
muted: Service.isConnected() && !Service.isListenOnly() && Service.isMuted(),
inAudio: Service.isConnected() && !Service.isEchoTest(),
listenOnly: Service.isConnected() && Service.isListenOnly(),
disable: Service.isConnecting() || Service.isHangingUp() || !Meteor.status().connected,
talking: Service.isTalking() && !Service.isMuted(),
currentUser: Service.currentUser(),
handleToggleMuteMicrophone: () => Service.toggleMuteMicrophone(),
handleJoinAudio: () => (Service.isConnected() ? Service.joinListenOnly() : mountModal(<AudioModalContainer />)),
handleLeaveAudio: () => Service.exitAudio(),
2019-05-24 00:47:56 +08:00
}))(AudioControlsContainer)));