Skip to content

Commit

Permalink
fix: move urlsAreEqual to base class so all connections benefit
Browse files Browse the repository at this point in the history
  • Loading branch information
jkeen committed Jan 11, 2024
1 parent f7d7435 commit efd16a2
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
12 changes: 12 additions & 0 deletions ember-stereo/src/stereo-connections/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -538,6 +538,18 @@ export default class Sound extends Evented {
assert('[ember-stereo] #stop interface not implemented', false);
}

urlsAreEqual(url1, url2) {
// GOTCHA: audio.src is a fully qualified URL, and this.url may be a relative url
// So when comparing, make sure we're dealing in absolutes

let parser1 = document.createElement('a');
let parser2 = document.createElement('a');
parser1.href = url1;
parser2.href = url2;

return parser1.href === parser2.href;
}

teardown() {
// optionally implemented in subclasses
this.isDestroyed = true;
Expand Down
12 changes: 0 additions & 12 deletions ember-stereo/src/stereo-connections/native-audio.js
Original file line number Diff line number Diff line change
Expand Up @@ -495,18 +495,6 @@ export default class NativeAudio extends BaseSound {
}
}

urlsAreEqual(url1, url2) {
// GOTCHA: audio.src is a fully qualified URL, and this.url may be a relative url
// So when comparing, make sure we're dealing in absolutes

let parser1 = document.createElement('a');
let parser2 = document.createElement('a');
parser1.href = url1;
parser2.href = url2;

return parser1.href === parser2.href;
}

teardown() {
let audio = this.requestControl();
this.durationWorkaroundTask.cancelAll();
Expand Down

0 comments on commit efd16a2

Please sign in to comment.