question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Safari Never Auto-Play setting causes long delay ending in `fileerror` with no information.

See original GitHub issue

Issue Details

  • Version used: 1.0.0

  • Describe whats happening: If desktop Safari is set to Never Auto-Play, after registering a sound, there is a several second delay, and then a fileerror event. The event doesn’t contain any info to determine that this setting was the cause.

Example

<!DOCTYPE html>

<html lang="en">
  <head>
    <meta charset="utf-8" />
    <title>Sound JS Test</title>
    <script src="https://code.createjs.com/1.0.0/soundjs.min.js"></script>
  </head>

  <body onload="setup()">
    <script>
      function setup() {
        console.log("setup");
        createjs.Sound.registerPlugins([createjs.HTMLAudioPlugin]);
      }

      function playSound() {
        console.log("playSound");
        
        createjs.Sound.on("fileload", function (result) {
          console.log("fileload", result);
          createjs.Sound.play("tone");
        });
        
        createjs.Sound.on("fileerror", function (error) {
          console.log("fileerror", error);
        });
        
        createjs.Sound.registerSound("audio/tone.mp3", "tone");
      }
    </script>

    <button onclick="playSound()">Play Sound</button>
  </body>
</html>

Resulting logs:

[Log] setup (sound-js, line 13)
[Log] playSound (sound-js, line 18)
[Log] fileerror (sound-js, line 24)

Event
  bubbles: false
  cancelable: false
  currentTarget: function()
  data: 100
  defaultPrevented: false
  eventPhase: 2
  id: "tone"
  immediatePropagationStopped: false
  propagationStopped: false
  removed: false
  sprite: undefined
  src: "audio/tone.mp3" 
  target: function()
  timeStamp: 1613432337722 
  type: "fileerror"
  Event Prototype
  • OS & Browser version Safari Version 14.0.3 (16610.4.3.1.4)

  • Do you know of any workarounds? Interestingly, if createjs.Sound.play("tone"); is called within the fileerror callback, the sounds still plays?! However, this is a ridiculous hack which breaks any other attempts at actually handling errors.

How can I react and or work around the Never Auto-Play setting in desktop Safari?

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:20 (11 by maintainers)

github_iconTop GitHub Comments

1reaction
curiousdustincommented, Feb 16, 2021

Thank you for the suggestion, however, I do not wish to preload sounds as my use case is streaming longer audio files. Which is also why I am using HTMLAudioPlugin.

0reactions
danzencommented, Mar 27, 2021

Hey @curiousdustin sorry for the delay - missed the response. I certainly see what you mean and am never happy with a polling solution especially when there are users that will not need it and we can’t seem to tell. Somehow I only seem to get in these binds with Apple.

What is frustrating is that the sound plays in the load test. We can capture that it plays. Yet when we stop it and try and play it again it will not play. Arrrg.

Your idea would at least get a sound playing. What would happen if we just paused the sound? Perhaps we can pass in a config object https://createjs.com/docs/soundjs/classes/PlayPropsConfig.html for the autoPlayOnSafari.

Anyway - will await your thoughts then see if we can code something. If you have a start, you are welcome to send it along. Cheers.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Stop autoplay videos in Safari on Mac - Apple Support
In the Safari app on your Mac, choose Safari > Settings, then click Websites. Click Auto-Play in the list on the left. Do...
Read more >
Video auto play is not working in Safari and Chrome desktop ...
As per this post in developers.google.com, From Chrome 53, the autoplay option is respected by the browser, if the video is muted.
Read more >
ChangeLog - Google Git
Reviewed by Youenn Fablet. This asserts because it appears that the WebContent and Networking process do not have the required entitlement. com.apple.private ...
Read more >
Fixing 'Error in Loading Media: File Could Not Be Played'
Learn how to fix this media file error in Chrome, Firefox, Safari and other browsers ... Steps to reset browser settings in Safari...
Read more >
F.B. Purity Help / FAQ - Clean up and Customize Facebook
If the disable autoplay setting does not exist on that page, try using a VPN to change the country you are accessing Facebook...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found