Skip to content

Commit

Permalink
Mobile autoplay bug fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
wjsc committed Feb 18, 2018
1 parent 1ae2b81 commit 62ae0b4
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/components/Player/Player.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ class Player extends React.Component {
);
this.trackCurrentTrack(this.props.state.tracks[this.props.state.current]);
};
this.element.load();
this.element.play();
}
componentWillUnmount() {
this.element.ontimeupdate = false;
Expand All @@ -47,7 +49,7 @@ class Player extends React.Component {
nextProps.state.status !== this.props.state.status && (nextProps.state.status === 'play' ? this.element.play() : this.element.pause());
}
renderAudio(currentTrack){
return <audio autoPlay ref={(element) => { this.element = element }}><source key={currentTrack._id} src={CDN_URL+currentTrack.audio} type="audio/mpeg"/></audio>;
return <audio ref={(element) => { this.element = element }}><source key={currentTrack._id} src={CDN_URL+currentTrack.audio} type="audio/mpeg"/></audio>;
}
render() {
const currentTrack = this.props.state.tracks[this.props.state.current];
Expand Down

0 comments on commit 62ae0b4

Please sign in to comment.