Skip to content

Commit

Permalink
fix: send pause event when releasing control of shared audio element
Browse files Browse the repository at this point in the history
  • Loading branch information
jkeen committed Nov 2, 2023
1 parent 74d5e05 commit f7fec45
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
8 changes: 8 additions & 0 deletions addon/-private/utils/shared-audio-access.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,17 @@ const log = debug('ember-stereo:shared-audio-access');
* out the src allows us to play a piece of audio seamlessly without requiring
* an extra click by the user to get around strict autoplay restrictions
*
* Note from late 2023:
* The above was true in 2016-2017, but not sure if it still stands. Apparently using
* a single element also solved some WNYC-specific issues with adswizz not allowing multiple
* connections at once (as documented in the changelog for 1.6.0). But again, not sure if that's
* worth keeping something that significantly complicates the codebase.
*
* @private
*/
/*
*/
export default class SharedAudioAccess {
audioElement;
owner;
Expand Down
8 changes: 4 additions & 4 deletions addon/stereo-connections/native-audio.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,10 +170,10 @@ export default class NativeAudio extends BaseSound {
return;
}

// if (this.isPlaying) {
// // send a pause event so anyone subscribed to stereo's relayed events gets the message
// this._onAudioPaused(this);
// }
// Send a pause event to ensure playback status is updated correctly.
// If this doesn't happen, the audio can get stuck in a playing state,
// even though it's not playing. https://github.com/jkeen/ember-stereo/issues/22
this._onAudioPaused(this);

this.sharedAudioAccess.releaseControl(this);
// save current state of audio element to the internal element that won't be played
Expand Down

0 comments on commit f7fec45

Please sign in to comment.