Files
Sdk_TV_app/templates/mobile_streams.html
T

257 lines
9.0 KiB
HTML

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title data-i18n="mobile.camera_streams">📱 Camera Streams</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimal-ui, viewport-fit=cover">
<link rel="stylesheet" href="/static/css/base.css">
<link rel="stylesheet" href="/static/css/navbar.css">
<link rel="stylesheet" href="/static/css/buttons.css">
<link rel="stylesheet" href="/static/css/components.css">
<link rel="stylesheet" href="/static/css/responsive.css">
<link rel="stylesheet" href="/static/css/pages/mobile_streams.css">
<script src="/static/js/i18n.js"></script>
</head>
<body>
<div class="mobile-navbar">
<div class="navbar-title">
<span data-i18n="mobile.camera_streams">📷 Prenosi Kamer</span>
{% if tournament_active %}
<span class="tournament-indicator">LIVE</span>
{% elif results_available %}
<span class="results-indicator">FINAL</span>
{% endif %}
</div>
<div class="navbar-controls">
<!-- Mobile users stay on mobile - no desktop access -->
</div>
</div>
<div class="container">
<div class="camera-selection">
{% for i in range(1, 7) %}
{% set camera_id = i %}
<div class="camera-option" onclick="openCameraFullscreen({{ camera_id }})">
<div class="stream-preview">
<div class="stream-loading" data-i18n="general.loading">Nalaganje...</div>
<img src="{{ streams[i-1].url }}"
alt="Camera {{ camera_id }}"
class="stream-img"
onerror="handleStreamError(this, {{ camera_id }})"
onload="handleStreamLoad(this)">
</div>
<div class="camera-info">
<div class="camera-title">
{% if tournament_active and current_round_data and (i-1) < current_round_data.players|length %}
{{ current_round_data.players[i-1].name }}
{% else %}
{{ settings.camera_titles[camera_id|string] }}
{% endif %}
</div>
</div>
</div>
{% endfor %}
</div>
</div>
<!-- Floating fullscreen button -->
<button class="floating-fullscreen-btn" onclick="toggleFullscreen()" id="fullscreenBtn">
⛶
</button>
<script>
function handleStreamError(img, cameraId) {
const streamPreview = img.parentElement;
const loadingIndicator = streamPreview.querySelector('.stream-loading');
// Add unavailable class to stream-preview
streamPreview.classList.add('unavailable');
if (loadingIndicator) {
loadingIndicator.textContent = 'Unavailable';
loadingIndicator.style.color = '#ff6b6b';
}
img.style.opacity = '0.1';
}
function handleStreamLoad(img) {
const loadingIndicator = img.parentElement.querySelector('.stream-loading');
if (loadingIndicator) {
loadingIndicator.style.display = 'none';
}
img.style.opacity = '1';
}
function openCameraFullscreen(cameraId) {
{% if tournament_active and current_round_data %}
const players = {{ current_round_data.players|tojson }};
let customTitle = `Camera ${cameraId}`;
if (cameraId <= players.length) {
customTitle = players[cameraId - 1].name;
}
{% else %}
const titles = {{ settings.camera_titles|tojson }};
const customTitle = titles[cameraId.toString()] || `Camera ${cameraId}`;
{% endif %}
const fullscreenUrl = `/fullscreen/${cameraId}?title=${encodeURIComponent(customTitle)}`;
if (screen.orientation && screen.orientation.lock) {
screen.orientation.lock('landscape').then(() => {
window.location.href = fullscreenUrl;
}).catch(() => {
window.location.href = fullscreenUrl;
});
} else {
window.location.href = fullscreenUrl;
}
}
function addMobileTouchFeedback() {
const touchElements = document.querySelectorAll('.camera-option, .nav-btn:not(.disabled), .floating-fullscreen-btn');
touchElements.forEach(element => {
element.addEventListener('touchstart', function(e) {
if (!this.disabled && !this.classList.contains('hidden')) {
this.style.transform = 'scale(0.95) translateY(0)';
this.style.transition = 'transform 0.1s ease';
}
});
element.addEventListener('touchend', function(e) {
if (!this.disabled && !this.classList.contains('hidden')) {
setTimeout(() => {
this.style.transform = '';
this.style.transition = 'transform 0.2s ease';
}, 100);
}
});
element.addEventListener('touchcancel', function(e) {
if (!this.disabled && !this.classList.contains('hidden')) {
this.style.transform = '';
this.style.transition = 'transform 0.2s ease';
}
});
});
}
// Keyboard shortcuts for quick camera selection
document.addEventListener('keydown', function(event) {
if (event.key >= '1' && event.key <= '6') {
const cameraId = parseInt(event.key);
openCameraFullscreen(cameraId);
}
});
function toggleFullscreen() {
const elem = document.documentElement;
if (!document.fullscreenElement) {
if (elem.requestFullscreen) {
elem.requestFullscreen();
} else if (elem.mozRequestFullScreen) {
elem.mozRequestFullScreen();
} else if (elem.webkitRequestFullscreen) {
elem.webkitRequestFullscreen();
} else if (elem.msRequestFullscreen) {
elem.msRequestFullscreen();
}
} else {
if (document.exitFullscreen) {
document.exitFullscreen();
} else if (document.mozCancelFullScreen) {
document.mozCancelFullScreen();
} else if (document.webkitExitFullscreen) {
document.webkitExitFullscreen();
} else if (document.msExitFullscreen) {
document.msExitFullscreen();
}
}
}
function handleFullscreenChange() {
const fullscreenBtn = document.getElementById('fullscreenBtn');
if (!fullscreenBtn) return;
const isFullscreen = document.fullscreenElement ||
document.mozFullScreenElement ||
document.webkitFullscreenElement ||
document.msFullscreenElement;
if (isFullscreen) {
fullscreenBtn.textContent = '⛶';
fullscreenBtn.classList.remove('hidden');
} else {
fullscreenBtn.textContent = '⛶';
fullscreenBtn.classList.remove('hidden');
// If we're coming back from a fullscreen camera view, redirect to streams
if (window.location.pathname.includes('/fullscreen/')) {
window.location.href = '/mobile/streams';
}
}
}
// Initialize
document.addEventListener('DOMContentLoaded', function() {
addMobileTouchFeedback();
handleFullscreenChange();
// Add fullscreen event listeners
document.addEventListener('fullscreenchange', handleFullscreenChange);
document.addEventListener('mozfullscreenchange', handleFullscreenChange);
document.addEventListener('webkitfullscreenchange', handleFullscreenChange);
document.addEventListener('msfullscreenchange', handleFullscreenChange);
console.log('📱 Mobile camera selection loaded with fixed navigation');
console.log('🏆 Tournament active:', {{ 'true' if tournament_active else 'false' }});
console.log('📊 Results available:', {{ 'true' if results_available else 'false' }});
setTimeout(() => {
if (window.innerHeight < window.screen.height) {
window.scrollBy(0, 1);
setTimeout(() => window.scrollBy(0, -1), 100);
}
}, 500);
// Only refresh streams if page is visible
setInterval(() => {
if (document.visibilityState !== 'visible') return;
const streams = document.querySelectorAll('.stream-img');
streams.forEach(stream => {
if (stream.complete && stream.naturalHeight === 0) {
stream.src = stream.src.split('?')[0] + '?refresh=' + Date.now();
}
});
}, 60000); // Reduced from 30s to 60s
if (window.innerHeight > window.innerWidth) {
const hint = document.createElement('div');
hint.style.cssText = `
position: fixed;
bottom: 90px;
left: 50%;
transform: translateX(-50%);
background: rgba(0, 0, 0, 0.8);
color: white;
padding: 10px 20px;
border-radius: 20px;
font-size: 0.9rem;
z-index: 999;
text-align: center;
`;
hint.textContent = '📱 Rotate to landscape or tap ⛶ for fullscreen';
document.body.appendChild(hint);
setTimeout(() => {
if (hint.parentNode) {
hint.parentNode.removeChild(hint);
}
}, 5000);
}
});
</script>
</body>
</html>