about summary refs log tree commit diff
path: root/app
diff options
context:
space:
mode:
authorThibG <thib@sitedethib.com>2020-08-02 18:47:09 +0200
committerThibaut Girka <thib@sitedethib.com>2020-08-02 22:30:51 +0200
commit8f0e6122a9cf85216d7e73bda5fa8338458b2b77 (patch)
tree0ca60f5d88936a2d768e29fe248f8d78eabd2581 /app
parentb578d709570508ea119056e7b65c289390b58887 (diff)
[Glitch] Fix audio player on Safari
Port 635b6a0f1af21bd4055f950930a681aa0a96535b to glitch-soc

Signed-off-by: Thibaut Girka <thib@sitedethib.com>
Diffstat (limited to 'app')
-rw-r--r--app/javascript/flavours/glitch/features/audio/index.js8
1 files changed, 4 insertions, 4 deletions
diff --git a/app/javascript/flavours/glitch/features/audio/index.js b/app/javascript/flavours/glitch/features/audio/index.js
index 33e67fcbe..f2c2fe4e0 100644
--- a/app/javascript/flavours/glitch/features/audio/index.js
+++ b/app/javascript/flavours/glitch/features/audio/index.js
@@ -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();
     }