Skip to main content
Participant
November 18, 2020
Question

Sound Cuts Off Before Completing in Google Chrome

  • November 18, 2020
  • 1 reply
  • 262 views

The audio doesn't play for the entire duration. It plays and stops partway, but seems to register as complete. I have an 'on complete' event. When the audio completes, the play/pause button changes from displaying the 'pause' icon to the 'play' icon. This happens the moment the audio stops, even if it didn't play for the entire duration.

 

This only happens intermittently and only in Google Chrome. I've found other posters in Stack Overflow who experienced this, but the question was asked a long time ago and I didn't see a suitable answer.

 

I'm currently using Adobe Animate 21.0 to produce HTML5 Canvas content.

 

It never occurs in IE/Edge. I have also not experienced this when loading in Chrome Incognito mode.

 

I've attached a sample of code. There are a few methods used, but this one is fairly simple, and I'm experiencing this issue.

 

There are several different events that trigger the sound, depending on the file used. In this example, a button plays/pauses the audio. What appears to happen is that the audio registers as 'complete' before it actually completes. The handleComplete event works as expected, just changes button states, but it sometimes occurs as soon as the audio stops (not when the entire file has played to completion).

mainMovieClip.play_btn.on("click", function(e){
	switch (mainMovieClip.play_btn.currentLabel) {
	case "uns":
		mainMovieClip.play_btn.gotoAndStop("sel");
		mainMovieClip.stop_btn.gotoAndStop("uns");
		createjs.Sound.stop();
		soundInstances.frameAudio = createjs.Sound.play("frameAudio", {volume: 1.0, loop: 0});
		soundInstances.frameAudio.on("complete", handleComplete);
	break;
	case "sel":
		mainMovieClip.play_btn.gotoAndStop("vis");
		soundInstances.frameAudio.paused = true;
	break;
	case "vis":
		mainMovieClip.play_btn.gotoAndStop("sel");
		soundInstances.frameAudio.paused = false;
	break;		
	
	}
});

 

    This topic has been closed for replies.

    1 reply

    kglad
    Community Expert
    Community Expert
    November 18, 2020

    what's soundInstances?

     

    and are you using that button more than once to play your sound and failing to remove duplicate complete handlers?

    Cam5C7EAuthor
    Participant
    December 11, 2020

    Apologies for not replying sooner - I didn't receive a notification that anyone had responded.

     

    The issue seems to have resolved. When the code was first created, everything worked as expected. After a time, the sound would cut off. Now it works again as expected. I'm speculating that Chrome introduced a bug in an update that was resolved shortly thereafter, but the code now works.

     

    In answer to your queries:

     

    soundInstances is an array of mp3 file names.

     

    As to the use of the button - it sounds like you have found an issue. Thank you for that. The button use will be very low as it is intended to play a narrated instruction that is quite short. It's there in case the user misses the autoplay audio. However, I don't want multiple handlers floating around, so thanks very much.

    kglad
    Community Expert
    Community Expert
    December 11, 2020

    you're welcome.