]> cat aescling's git repositories - mastodon.git/commitdiff
[Glitch] Fix audio player on Safari
authorThibG <thib@sitedethib.com>
Sun, 2 Aug 2020 16:47:09 +0000 (18:47 +0200)
committerThibaut Girka <thib@sitedethib.com>
Sun, 2 Aug 2020 20:30:51 +0000 (22:30 +0200)
Port 635b6a0f1af21bd4055f950930a681aa0a96535b to glitch-soc

Signed-off-by: Thibaut Girka <thib@sitedethib.com>
app/javascript/flavours/glitch/features/audio/index.js

index 33e67fcbe38c19fa23499ed3fb35baae746d4f28..f2c2fe4e0cdfe5fe5432d3366d58d204860154b7 100644 (file)
@@ -113,6 +113,10 @@ class Audio extends React.PureComponent {
   }
 
   togglePlay = () => {
+    if (!this.audioContext) {
+      this._initAudioContext();
+    }
+
     if (this.state.paused) {
       this.setState({ paused: false }, () => this.audio.play());
     } else {
@@ -131,10 +135,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();
     }