Skip to content

Commit

Permalink
Fix webrtc play event for firefox
Browse files Browse the repository at this point in the history
  • Loading branch information
mrlt8 committed Jun 24, 2024
1 parent 1fdbc3a commit 1a42ba4
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 10 deletions.
6 changes: 3 additions & 3 deletions app/static/site.js
Original file line number Diff line number Diff line change
Expand Up @@ -691,9 +691,9 @@ document.addEventListener("DOMContentLoaded", () => {
}
// Click to load WebRTC

document.querySelectorAll('[data-enabled=True] video.webrtc.placeholder').forEach((v) => {
v.parentElement.addEventListener("click", () => { loadWebRTC(v, true) }, { "once": true });
v.addEventListener('pause', () => { v.removeAttribute('autoplay'); });
document.querySelectorAll('[data-enabled=True] video.webrtc.placeholder').forEach((videoElement) => {
videoElement.addEventListener("play", () => { loadWebRTC(videoElement) }, { "once": true });
videoElement.addEventListener('pause', () => { videoElement.removeAttribute('autoplay'); });
});
// Auto-play video
function autoplay(action) {
Expand Down
7 changes: 0 additions & 7 deletions app/static/webrtc.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,17 +138,10 @@ class Receiver {
let vid = document.querySelector(`video[data-cam='${this.signalJson.cam}']`);
vid.srcObject = event.streams[0];
vid.autoplay = true;
vid.playsInline = true;
vid.play().catch((err) => {
console.info('play() error:', err);
});
}
play(video) {
video.autoplay = true;
video.playsInline = true;
return video.play();
}


onConnectionStateChange() {
if (this.restartTimeout !== null) { return; }
Expand Down

0 comments on commit 1a42ba4

Please sign in to comment.