bigbluebutton-Github/bigbluebutton-html5/imports/ui/components/chat/alert/audio-alert/component.jsx

45 lines
1011 B
React
Raw Normal View History

import { Component } from 'react';
import PropTypes from 'prop-types';
import AudioService from '/imports/ui/components/audio/service';
2020-12-01 00:09:35 +08:00
import {Meteor} from "meteor/meteor";
const propTypes = {
play: PropTypes.bool.isRequired,
};
class ChatAudioAlert extends Component {
constructor(props) {
super(props);
this.handleAudioLoaded = this.handleAudioLoaded.bind(this);
this.playAudio = this.playAudio.bind(this);
}
componentDidMount() {
this.handleAudioLoaded();
}
componentWillUnmount() {
this.handleAudioLoaded();
}
handleAudioLoaded() {
2019-01-14 21:23:35 +08:00
this.componentDidUpdate = this.playAudio;
}
playAudio() {
2019-01-14 21:23:35 +08:00
const { play } = this.props;
if (!play) return;
AudioService.playAlertSound(`${Meteor.settings.public.app.cdn
2020-12-01 00:09:35 +08:00
+ Meteor.settings.public.app.basename
+ Meteor.settings.public.app.instanceId}`
+ '/resources/sounds/notify.mp3');
}
render() {
return null;
}
}
2018-08-15 10:35:58 +08:00
ChatAudioAlert.propTypes = propTypes;
2018-08-15 10:35:58 +08:00
export default ChatAudioAlert;