scottschiller / SoundManager2

A JavaScript Sound API supporting MP3, MPEG4 and HTML5 audio + RTMP, providing reliable cross-browser/platform audio control in as little as 12 KB. BSD licensed.
http://www.schillmania.com/projects/soundmanager2/
Other
4.99k stars 768 forks source link

onload behavior is different on mac osX chrome 67 #217

Open elschaefo opened 6 years ago

elschaefo commented 6 years ago

Hi ALL

this is driving me nuts and I can't seem to figure out a solution so posting here. To be fair, it sure seems like a Chrome issue and not a Soundmanager issue but... anyone have a tip for my problem ?

soundmanager : soundmanagerv297a-20170601

using this version of Chrome on mac OSX

Version 67.0.3396.62 (Official Build) (64-bit)

the onload event for play does not fire for Chrome, but it does for Safari and FF.

whats even weirder is that if I put in a Bad stream URL to force the stream to fail, the onload does fire !

with the correct stream URL, the sound plays just fine, it just wont tell me if there was a successful onload or not in Chrome.

THis is a bummer for us because we use it to keep track of successful vs unsuccessful logins (and fire some other logic, like the streamDead() function, which displays a message to the user that we couldnt connect etc)

anyone else come across this behavior ?


   function playStream() {
       soundManager.play(soundID,{
           url: 'http://www.somevalidmp3stream.com',
           onload: function(bSuccess) {
            // if the stream is dead, show dead message immediately
            if (!bSuccess) {
                streamDead();
                logTuneIn(false);
            }
            if (bSuccess) {
                logTuneIn(true);
            }
            soundManager._writeDebug('sound '+(bSuccess?'loaded!': 'did NOT load.'));
          }
       });

   }

     var sound = soundManager.createSound({
       id: soundID,
       url: 'http://www.somevalidmp3stream.com',
       multiShot: false,
       autoPlay: false,
       volume: currentVolume
   });
scottschiller commented 6 years ago

I apologize for a super-late reply on this. Chrome has introduced some auto-play-type restrictions, you can start sound playback only immediately in response to a user action like click or tap - no setTimeout() or other async shenanigans.

You should be able to omit autoPlay entirely here, the default SM2 config is not to do so because it's annoying and causes so many problems for users. In fact, I should remove it. ;)

Let me know if this was resolved with a future Chrome update, or nay.