Skip to content

Commit

Permalink
feat: add webui debuger mute audio and video
Browse files Browse the repository at this point in the history
  • Loading branch information
a-wing committed Feb 3, 2024
1 parent b6f9241 commit 7c8a56f
Showing 1 changed file with 22 additions and 11 deletions.
33 changes: 22 additions & 11 deletions assets/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,11 @@ <h3>WHIP Video:</h3>
<center>
<section>SVC Layer: <select disabled id="whep-layer-select"></select></section>
<section>
<button onclick="startWhep()">Start</button>
<button id="whep-button-disable-audio">Disable Audio</button>
<button id="whep-button-disable-video">Disable Video</button>
</section>
<section>
<button onclick="startWhep()">Start</button>
<button id="whep-button-stop">Stop</button>
</section>

Expand Down Expand Up @@ -291,9 +294,6 @@ <h3>WHEP Video:</h3>
if (el) el.srcObject = null
}

// leave page
// addEventListener("beforeunload", stop)

const element = document.getElementById(idWhipButtonStop)
if (element) element.addEventListener('click', stop)

Expand All @@ -307,6 +307,8 @@ <h3>WHEP Video:</h3>

const idWhepLayerSelect = "whep-layer-select"
const idWhepButtonStop = "whep-button-stop"
const idWhepButtonDisableAudio = "whep-button-disable-audio"
const idWhepButtonDisableVideo = "whep-button-disable-video"
const idWhepDataChannel = "whep-datachannel"

initLayerSelect(idWhepLayerSelect, [
Expand Down Expand Up @@ -356,14 +358,23 @@ <h3>WHEP Video:</h3>
await whep.stop()
logWhep(num, "stopped")
})
var flag = false
document.getElementById("whep-button-disable-video").onclick = async () => {
await whep.mute({
"kind":"video",
"audioEnabled": flag
})
flag = !flag

const buttonDisableAudio = document.getElementById(idWhepButtonDisableAudio)
let flagButtonDisableAudio = false
buttonDisableAudio.onclick = async () => {
await whep.mute({ kind: "audio", enabled: flagButtonDisableAudio })
buttonDisableAudio.innerText = flagButtonDisableAudio ? "Disable Audio" : "Enable Audio"
flagButtonDisableAudio = !flagButtonDisableAudio
}

const buttonDisableVideo = document.getElementById(idWhepButtonDisableVideo)
let flagButtonDisableVideo = false
buttonDisableVideo.onclick = async () => {
await whep.mute({ kind: "video", enabled: flagButtonDisableVideo })
buttonDisableVideo.innerText = flagButtonDisableVideo ? "Disable Video" : "Enable Video"
flagButtonDisableVideo = !flagButtonDisableVideo
}

const initEvevt = () => {
const el = document.getElementById(idWhepLayerSelect)
if (el) el.onchange = ev => !ev.target.value ? whep.unselectLayer() : whep.selectLayer({"encodingId": ev.target.value}).catch(e => logWhep(e))
Expand Down

0 comments on commit 7c8a56f

Please sign in to comment.