add embed page
This commit is contained in:
33
public/embed.html
Normal file
33
public/embed.html
Normal file
@@ -0,0 +1,33 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Screenshare - Embed</title>
|
||||
<style>
|
||||
body, html {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
background: #000;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
overflow: hidden;
|
||||
}
|
||||
video {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
object-fit: contain;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<video id="remoteVideo" autoplay playsinline controls muted></video>
|
||||
|
||||
<script src="/socket.io/socket.io.js"></script>
|
||||
<script src="mediasoup-client.js"></script>
|
||||
<script src="viewer.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -12,7 +12,8 @@ document.addEventListener('click', () => { hasUserInteracted = true; }, { once:
|
||||
document.addEventListener('touchstart', () => { hasUserInteracted = true; }, { once: true });
|
||||
|
||||
// Make overlay clickable to start playback on mobile
|
||||
overlay.addEventListener('click', () => {
|
||||
if (overlay) {
|
||||
overlay.addEventListener('click', () => {
|
||||
if (remoteVideo.srcObject) {
|
||||
remoteVideo.muted = false;
|
||||
remoteVideo.play().then(() => {
|
||||
@@ -20,17 +21,20 @@ overlay.addEventListener('click', () => {
|
||||
remoteVideo.classList.add('active');
|
||||
}).catch(e => console.error('Play failed:', e));
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function tryPlay() {
|
||||
remoteVideo.play().then(() => {
|
||||
overlay.classList.add('hidden');
|
||||
if (overlay) overlay.classList.add('hidden');
|
||||
remoteVideo.classList.add('active');
|
||||
}).catch(() => {
|
||||
// Autoplay blocked — show tap prompt
|
||||
if (overlay) {
|
||||
overlay.classList.remove('hidden');
|
||||
overlay.querySelector('h1').innerText = 'Tap to Play';
|
||||
overlay.querySelector('.status-indicator span:last-child').innerText = 'Stream ready — tap anywhere';
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -171,7 +175,7 @@ socket.on('producerClosed', ({ consumerId }) => {
|
||||
if (Object.keys(consumers).length === 0) {
|
||||
remoteVideo.classList.remove('active');
|
||||
remoteVideo.srcObject = null;
|
||||
overlay.classList.remove('hidden');
|
||||
if (overlay) overlay.classList.remove('hidden');
|
||||
}
|
||||
});
|
||||
|
||||
@@ -201,9 +205,11 @@ socket.on('broadcasterDisconnected', () => {
|
||||
remoteVideo.classList.remove('active');
|
||||
remoteVideo.srcObject = null;
|
||||
|
||||
if (overlay) {
|
||||
overlay.classList.remove('hidden');
|
||||
overlay.querySelector('h1').innerText = 'Offline';
|
||||
overlay.querySelector('.status-indicator span:last-child').innerText = 'Waiting for new stream...';
|
||||
}
|
||||
});
|
||||
|
||||
// Initialize on connect
|
||||
|
||||
Reference in New Issue
Block a user