Skip to content

Commit 9ec4059

Browse files
author
kubraturan
committed
Meeting item to add meetSoundPlay props.
1 parent b29f39a commit 9ec4059

2 files changed

Lines changed: 34 additions & 0 deletions

File tree

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -656,6 +656,7 @@ import { MeetingItem } from 'react-chat-elements'
656656
| onCloseClick | none | function | MeetingItem on close click |
657657
| avatars | none | date | MeetingItem avatars |
658658
| avatarLimit | 5 | date | MeetingItem avatars limit |
659+
| meetSoundPlay| null | object | MeetingItem to add sound |
659660

660661

661662
## MeetingList Component

src/MeetingItem/MeetingItem.js

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,32 @@ import classNames from 'classnames';
1515

1616
export class MeetingItem extends Component {
1717

18+
componentDidMount() {
19+
if (this.props.meetSoundPlay && this.props.meetSoundPlay.play)
20+
this.playSound();
21+
}
22+
23+
componentWillReceiveProps(nextProps) {
24+
if (nextProps.meetSoundPlay) {
25+
if (nextProps.meetSoundPlay.play)
26+
this.playSound();
27+
else
28+
this.closeSound();
29+
}
30+
}
31+
32+
playSound() {
33+
var meetSound = this.refs['meetSound'];
34+
meetSound.autoplay = true;
35+
meetSound.loop = true;
36+
};
37+
38+
closeSound() {
39+
var meetSound = this.refs['meetSound'];
40+
meetSound.pause();
41+
meetSound.currentTime = 0;
42+
}
43+
1844
render() {
1945
const statusColorType = this.props.statusColorType;
2046
const AVATAR_LIMIT = this.props.avatarLimit;
@@ -31,6 +57,12 @@ export class MeetingItem extends Component {
3157
className={classNames('rce-container-mtitem', this.props.className)}
3258
onClick={this.props.onClick}
3359
onContextMenu={this.props.onContextMenu}>
60+
61+
<audio
62+
ref="meetSound"
63+
src={this.props.meetSoundPlay && this.props.meetSoundPlay.src}
64+
autoPlay/>
65+
3466
<div className="rce-mtitem">
3567
<div className="rce-mtitem-top">
3668
<div className="rce-mtitem-subject">
@@ -121,6 +153,7 @@ MeetingItem.defaultProps = {
121153
lazyLoadingImage: undefined,
122154
avatarLimit: 5,
123155
avatars: [],
156+
meetSoundPlay: null,
124157
onAvatarError: () => void(0),
125158
onMeetingClick: () => void(0),
126159
onShareClick: () => void(0),

0 commit comments

Comments
 (0)