unmute me

This commit is contained in:
legop3
2026-07-11 03:33:19 -04:00
parent c06ac6bc20
commit 0c0b55fe88
6 changed files with 57 additions and 14 deletions
+9 -2
View File
@@ -29,12 +29,19 @@ function buildAuthHeader(token) {
}
export class WhepPlayer {
constructor({ url, token, video, onStatus, audioOnly = false, receiveAudio = true }) {
constructor({ url, token, video, onStatus, audioOnly = false, receiveAudio = true, startMuted = null }) {
this.url = url;
this.token = token;
this.video = video;
this.audioOnly = audioOnly;
this.receiveAudio = receiveAudio;
/*
Browser autoplay usually requires normal video streams to start muted,
while audio-only streams need to start audible. Keep that historical
default, but allow a caller that is already behind a user gesture, such as
the PTZ fullscreen controller, to request audible inline audio.
*/
this.startMuted = startMuted === null ? !audioOnly : Boolean(startMuted);
this.pc = null;
this.abortController = null;
this.onStatus = onStatus;
@@ -50,7 +57,7 @@ export class WhepPlayer {
if (!this.video) return;
this.video.playsInline = true;
this.video.autoplay = true;
this.video.muted = this.audioOnly ? false : true;
this.video.muted = this.startMuted;
if (typeof this.video.disableRemotePlayback !== 'undefined') {
this.video.disableRemotePlayback = true;
}