Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 31 additions & 1 deletion apps/lvpr-tv/src/components/IframeMessenger.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,37 @@ export function IframeMessenger() {
return;
}

//console.log("Received message from parent:", event.data);
console.log("Received message from parent:", event.data);

if (event.data.type === "lvpr-player-control") {
const { action, value } = event.data;

if (action === "setMuted") {
const videoElement = document.querySelector('video[data-livepeer-video]') as HTMLVideoElement;
if (videoElement) {
if (value) {
videoElement.volume = 0;
videoElement.muted = true;
} else {
videoElement.volume = 1;
videoElement.muted = false;
}

if (window.parent && window.parent !== window) {
window.parent.postMessage(
{
type: "lvpr-player-mute-changed",
muted: value,
timestamp: Date.now(),
},
"*",
);
}
} else {
console.error("Could not find video element to control");
}
}
}
};

const sendReady = () => {
Expand Down
Loading