This guide explains how to show a full-screen message prompting users to rotate their device. The message automatically hides when the device is in landscape mode. It works on all devices (mobile, tablet, desktop).
Follow the steps below:
Step 1: Update message.js
-
Open your
message.jsfile. -
Add the following function outside the
messageHandlerfunction:
function handleRotationChange() {
const overlay = document.getElementById("rotateOverlay");
if (!overlay) return;
// If device is in landscape, hide the message
if (window.innerWidth > window.innerHeight) {
overlay.style.display = "none";
} else {
overlay.style.display = "flex";
}
}
// Listen for rotation & resize (desktop + mobile)
window.addEventListener("orientationchange", handleRotationChange);
window.addEventListener("resize", handleRotationChange);
-
Inside the
messageHandlerfunction, locate thecase "stage4_playBtnShowedUp":block.
Add the following lines to show the overlay and immediately check orientation:
document.getElementById("rotateOverlay").style.display = "flex";
handleRotationChange(); // immediately check orientation
-
Inside the
messageHandlerfunction, locate thecase "stage5_playBtnPressed":block.
Add the following lines to hide the screen rotation message
document.getElementById("rotateOverlay").style.display = "none";
Step 2: Add CSS Styles
Add the following CSS to your style.css file or inside a <style> block in your HTML:
#rotateOverlay {
position: fixed;
top: 0;
left: 0;
width: 100vw;
height: 100vh;
background: rgba(0, 0, 0, 0.85);
display: none; /* hidden by default */
align-items: center;
justify-content: center;
z-index: 99999;
}
.rotateMessage {
color: #ffffff;
font-size: 32px;
font-weight: 600;
text-align: center;
}
Notes:
-
z-index: 99999ensures the overlay covers the iframe and all other elements. -
The overlay is hidden by default (
display: none) and will only appear when needed.
Step 3: Add the Overlay HTML
Place the following <div> just before the closing </body> tag in your HTML file:
<div id="rotateOverlay">
<div class="rotateMessage">
🔄 Rotate the screen // add your customized message here
</div>
</div>
Notes:
-
Placing it outside any modal ensures it always appears above the iframe.
-
The
rotateMessagediv contains the icon/text that will be shown to users.
Behavior After Setup
-
When the Play button appears (
stage4_playBtnShowedUp), the “Rotate the screen” overlay will appear. -
If the device is already in landscape, the overlay will be hidden automatically.
-
The overlay automatically updates when the device orientation changes.
-
Once streaming starts (
stage5_playBtnPressed), the overlay is automatically hidden if not already.
Note: This setup is provided for demo purposes. You can customize the message, icon, text, or styling as per your app’s requirements.
Need help?
🛠️ Contact our Support Team
💬 Join the Community on Discord
Follow us on: