]> cat aescling's git repositories - mastodon.git/commitdiff
Fix audio player on Safari (#14485)
authorThibG <thib@sitedethib.com>
Sun, 2 Aug 2020 16:47:09 +0000 (18:47 +0200)
committerGitHub <noreply@github.com>
Sun, 2 Aug 2020 16:47:09 +0000 (18:47 +0200)
app/javascript/mastodon/features/audio/index.js

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