Skip to content

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

@dustinbahr

Description

@dustinbahr

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions