2017-08-04 20:24:57 +08:00
|
|
|
import React from 'react';
|
2017-03-28 04:40:44 +08:00
|
|
|
import { createContainer } from 'meteor/react-meteor-data';
|
2017-05-02 03:52:57 +08:00
|
|
|
import { withModalMounter } from '/imports/ui/components/modal/service';
|
2017-10-19 03:40:01 +08:00
|
|
|
import { injectIntl, defineMessages } from 'react-intl';
|
2017-08-04 20:24:57 +08:00
|
|
|
import PropTypes from 'prop-types';
|
2017-05-02 03:52:57 +08:00
|
|
|
import Service from './service';
|
2017-03-28 04:40:44 +08:00
|
|
|
import Audio from './component';
|
2017-09-29 21:38:10 +08:00
|
|
|
import AudioModalContainer from './audio-modal/container';
|
2017-03-28 04:40:44 +08:00
|
|
|
|
2017-08-04 20:24:57 +08:00
|
|
|
const propTypes = {
|
|
|
|
children: PropTypes.element,
|
|
|
|
};
|
|
|
|
|
|
|
|
const defaultProps = {
|
|
|
|
children: null,
|
|
|
|
};
|
2017-03-28 04:40:44 +08:00
|
|
|
|
2017-10-19 03:40:01 +08:00
|
|
|
const intlMessages = defineMessages({
|
|
|
|
joinedAudio: {
|
|
|
|
id: 'app.audioManager.joinedAudio',
|
|
|
|
description: 'Joined audio toast message',
|
|
|
|
},
|
2017-10-23 20:41:09 +08:00
|
|
|
joinedEcho: {
|
2017-10-19 03:40:01 +08:00
|
|
|
id: 'app.audioManager.joinedEcho',
|
|
|
|
description: 'Joined echo test toast message',
|
|
|
|
},
|
|
|
|
leftAudio: {
|
|
|
|
id: 'app.audioManager.leftAudio',
|
|
|
|
description: 'Left audio toast message',
|
|
|
|
},
|
|
|
|
genericError: {
|
|
|
|
id: 'app.audioManager.genericError',
|
|
|
|
description: 'Generic error messsage',
|
|
|
|
},
|
|
|
|
connectionError: {
|
|
|
|
id: 'app.audioManager.connectionError',
|
|
|
|
description: 'Connection error messsage',
|
|
|
|
},
|
|
|
|
requestTimeout: {
|
|
|
|
id: 'app.audioManager.requestTimeout',
|
|
|
|
description: 'Request timeout error messsage',
|
|
|
|
},
|
|
|
|
invalidTarget: {
|
|
|
|
id: 'app.audioManager.invalidTarget',
|
|
|
|
description: 'Invalid target error messsage',
|
|
|
|
},
|
2017-10-27 01:14:56 +08:00
|
|
|
mediaError: {
|
|
|
|
id: 'app.audioManager.mediaError',
|
|
|
|
description: 'Media error messsage',
|
|
|
|
},
|
2017-10-19 03:40:01 +08:00
|
|
|
});
|
|
|
|
|
|
|
|
|
2017-10-31 18:53:06 +08:00
|
|
|
const AudioContainer = props => <Audio {...props} />;
|
2017-05-04 05:39:07 +08:00
|
|
|
|
2017-08-15 03:19:35 +08:00
|
|
|
let didMountAutoJoin = false;
|
2017-08-05 04:33:25 +08:00
|
|
|
|
2017-10-19 03:40:01 +08:00
|
|
|
export default withModalMounter(injectIntl(createContainer(({ mountModal, intl }) => {
|
2017-04-20 04:42:48 +08:00
|
|
|
const APP_CONFIG = Meteor.settings.public.app;
|
2017-03-28 04:40:44 +08:00
|
|
|
|
2017-08-04 20:24:57 +08:00
|
|
|
const { autoJoinAudio } = APP_CONFIG;
|
|
|
|
|
2017-10-19 03:40:01 +08:00
|
|
|
const messages = {
|
|
|
|
info: {
|
|
|
|
JOINED_AUDIO: intl.formatMessage(intlMessages.joinedAudio),
|
|
|
|
JOINED_ECHO: intl.formatMessage(intlMessages.joinedEcho),
|
|
|
|
LEFT_AUDIO: intl.formatMessage(intlMessages.leftAudio),
|
|
|
|
},
|
|
|
|
error: {
|
|
|
|
GENERIC_ERROR: intl.formatMessage(intlMessages.genericError),
|
|
|
|
CONNECTION_ERROR: intl.formatMessage(intlMessages.connectionError),
|
|
|
|
REQUEST_TIMEOUT: intl.formatMessage(intlMessages.requestTimeout),
|
|
|
|
INVALID_TARGET: intl.formatMessage(intlMessages.invalidTarget),
|
|
|
|
},
|
2017-10-23 20:41:09 +08:00
|
|
|
};
|
2017-10-19 03:40:01 +08:00
|
|
|
|
2017-03-28 04:40:44 +08:00
|
|
|
return {
|
2017-05-02 03:52:57 +08:00
|
|
|
init: () => {
|
2017-10-19 03:40:01 +08:00
|
|
|
Service.init(messages);
|
2017-10-23 20:41:09 +08:00
|
|
|
Service.changeOutputDevice(document.querySelector('#remote-media').sinkId);
|
2017-08-15 03:19:35 +08:00
|
|
|
if (!autoJoinAudio || didMountAutoJoin) return;
|
2017-09-29 21:38:10 +08:00
|
|
|
mountModal(<AudioModalContainer />);
|
2017-08-15 03:19:35 +08:00
|
|
|
didMountAutoJoin = true;
|
2017-05-02 03:52:57 +08:00
|
|
|
},
|
2017-03-28 04:40:44 +08:00
|
|
|
};
|
2017-10-19 03:40:01 +08:00
|
|
|
}, AudioContainer)));
|
2017-08-04 20:24:57 +08:00
|
|
|
|
|
|
|
AudioContainer.propTypes = propTypes;
|
2017-10-19 03:40:01 +08:00
|
|
|
AudioContainer.defaultProps = defaultProps;
|