Skip to content

Commit

Permalink
Fix Firefox support
Browse files Browse the repository at this point in the history
Setting the audio sink without checking if it exists was blocking
FireFox users from recieving.
  • Loading branch information
bekriebel committed Mar 27, 2021
1 parent bf7c2fa commit e05d81c
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions scripts/walkie-talkie.js
Original file line number Diff line number Diff line change
Expand Up @@ -250,12 +250,15 @@ class WalkieTalkie {
audioElement = document.createElement("audio");
audioElement.className = "player-walkie-talkie-audio";
audioElement.autoplay = true;
audioElement.setSinkId(audioSink).then(() => {
this.debug("Audio output set:", audioSink);
}).catch((err) => {
this.onError("Error setting audio output device:", err);
});

if (typeof audioElement.sinkId !== "undefined") {
audioElement.setSinkId(audioSink).then(() => {
this.debug("Audio output set:", audioSink);
}).catch((err) => {
this.onError("Error setting audio output device:", err);
});
} else {
this.debug("Browser does not support output device selection");
}
// Place the audio element after the button
buttonElement.after(audioElement);
}
Expand Down

0 comments on commit e05d81c

Please sign in to comment.