Fix audio player on Safari (#14485)

This commit is contained in:
ThibG 2020-08-02 18:47:09 +02:00 committed by GitHub
parent 3ade834830
commit 635b6a0f1a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 4 deletions

View File

@ -115,6 +115,10 @@ class Audio extends React.PureComponent {
} }
togglePlay = () => { togglePlay = () => {
if (!this.audioContext) {
this._initAudioContext();
}
if (this.state.paused) { if (this.state.paused) {
this.setState({ paused: false }, () => this.audio.play()); this.setState({ paused: false }, () => this.audio.play());
} else { } else {
@ -133,10 +137,6 @@ class Audio extends React.PureComponent {
handlePlay = () => { handlePlay = () => {
this.setState({ paused: false }); this.setState({ paused: false });
if (this.canvas && !this.audioContext) {
this._initAudioContext();
}
if (this.audioContext && this.audioContext.state === 'suspended') { if (this.audioContext && this.audioContext.state === 'suspended') {
this.audioContext.resume(); this.audioContext.resume();
} }