I’m building a custom website and want to add streaming video functionality. The goal is to have the page load without any video content visible, then use JavaScript buttons to toggle the streaming player and chat window on and off. I’m having trouble getting the toggle functionality to work properly. Any suggestions would be helpful!
<button onclick="toggleVideo()">Show/Hide Video Stream</button>
<button onclick="toggleMessages()">Show/Hide Messages</button>
<script>
var videoVisible = false;
function toggleVideo() {
if(videoVisible == false) {
videoVisible = true;
document.getElementById("VideoStream").style.display = "block";
} else {
videoVisible = false;
document.getElementById("VideoStream").style.display = "none";
}
}
var messagesVisible = false;
function toggleMessages() {
if(messagesVisible == false) {
messagesVisible = true;
document.getElementById("MessageBox").style.display = "block";
} else {
messagesVisible = false;
document.getElementById("MessageBox").style.display = "none";
}
}
</script>
<iframe id="VideoStream" src="streaming-video-url" width="1200" height="675"></iframe>
<iframe id="MessageBox" src="chat-messages-url" width="350" height="675"></iframe>