274 lines
8.7 KiB
HTML
274 lines
8.7 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>{{ player.username }} - Digital Signage Display</title>
|
|
<style>
|
|
* {
|
|
margin: 0;
|
|
padding: 0;
|
|
box-sizing: border-box;
|
|
}
|
|
|
|
body {
|
|
background: #000;
|
|
color: #fff;
|
|
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
|
|
overflow: hidden;
|
|
cursor: none;
|
|
}
|
|
|
|
.fullscreen-container {
|
|
width: 100vw;
|
|
height: 100vh;
|
|
position: relative;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
}
|
|
|
|
.content-item {
|
|
width: 100%;
|
|
height: 100%;
|
|
display: none;
|
|
align-items: center;
|
|
justify-content: center;
|
|
position: absolute;
|
|
top: 0;
|
|
left: 0;
|
|
}
|
|
|
|
.content-item.active {
|
|
display: flex;
|
|
}
|
|
|
|
.content-item img {
|
|
max-width: 100%;
|
|
max-height: 100%;
|
|
object-fit: contain;
|
|
}
|
|
|
|
.content-item video {
|
|
width: 100%;
|
|
height: 100%;
|
|
object-fit: cover;
|
|
}
|
|
|
|
.no-content {
|
|
text-align: center;
|
|
color: #666;
|
|
}
|
|
|
|
.no-content h1 {
|
|
font-size: 3rem;
|
|
margin-bottom: 1rem;
|
|
}
|
|
|
|
.no-content p {
|
|
font-size: 1.5rem;
|
|
}
|
|
|
|
.player-info {
|
|
position: absolute;
|
|
bottom: 20px;
|
|
right: 20px;
|
|
background: rgba(0,0,0,0.7);
|
|
padding: 10px 15px;
|
|
border-radius: 5px;
|
|
font-size: 0.9rem;
|
|
z-index: 1000;
|
|
}
|
|
|
|
.loading {
|
|
position: absolute;
|
|
top: 50%;
|
|
left: 50%;
|
|
transform: translate(-50%, -50%);
|
|
font-size: 2rem;
|
|
color: #666;
|
|
}
|
|
|
|
.error-message {
|
|
color: #ff6b6b;
|
|
text-align: center;
|
|
font-size: 1.5rem;
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<div class="fullscreen-container">
|
|
<div id="loading" class="loading">
|
|
<i>⟳</i> Loading content...
|
|
</div>
|
|
|
|
{% if content %}
|
|
{% for item in content %}
|
|
<div class="content-item" data-duration="{{ item.duration }}" data-id="{{ item.id }}">
|
|
{% if item.content_type.startswith('image/') %}
|
|
<img src="{{ url_for('static', filename='uploads/' + item.file_name) }}"
|
|
alt="{{ item.original_name or item.file_name }}">
|
|
{% elif item.content_type.startswith('video/') %}
|
|
<video muted autoplay>
|
|
<source src="{{ url_for('static', filename='uploads/' + item.file_name) }}"
|
|
type="{{ item.content_type }}">
|
|
</video>
|
|
{% endif %}
|
|
</div>
|
|
{% endfor %}
|
|
{% else %}
|
|
<div class="no-content">
|
|
<h1>📺</h1>
|
|
<h2>{{ player.username }}</h2>
|
|
<p>No content available</p>
|
|
<p style="margin-top: 2rem; font-size: 1rem; color: #888;">
|
|
Waiting for content assignment...
|
|
</p>
|
|
</div>
|
|
{% endif %}
|
|
|
|
<div class="player-info">
|
|
<div>{{ player.username }}</div>
|
|
<div style="font-size: 0.8rem; color: #ccc;">{{ player.hostname }}</div>
|
|
<div style="font-size: 0.7rem; color: #999;">Last updated: <span id="lastUpdate">--:--:--</span></div>
|
|
</div>
|
|
</div>
|
|
|
|
<script>
|
|
class DigitalSignagePlayer {
|
|
constructor() {
|
|
this.contentItems = document.querySelectorAll('.content-item');
|
|
this.currentIndex = 0;
|
|
this.isPlaying = false;
|
|
this.refreshInterval = 30000; // 30 seconds
|
|
this.playerId = {{ player.id|tojson }};
|
|
|
|
this.init();
|
|
}
|
|
|
|
init() {
|
|
// Hide loading
|
|
document.getElementById('loading').style.display = 'none';
|
|
|
|
// Set initial time
|
|
this.updateDisplayTime();
|
|
|
|
if (this.contentItems.length > 0) {
|
|
this.startSlideshow();
|
|
} else {
|
|
console.log('No content available');
|
|
}
|
|
|
|
// Set up content refresh
|
|
setInterval(() => this.checkForUpdates(), this.refreshInterval);
|
|
|
|
// Update last update time
|
|
setInterval(() => this.updateLastSeen(), 60000);
|
|
}
|
|
|
|
startSlideshow() {
|
|
if (this.contentItems.length === 0) return;
|
|
|
|
this.isPlaying = true;
|
|
this.showContent(0);
|
|
}
|
|
|
|
showContent(index) {
|
|
if (index >= this.contentItems.length) {
|
|
index = 0;
|
|
}
|
|
|
|
// Hide all content
|
|
this.contentItems.forEach(item => {
|
|
item.classList.remove('active');
|
|
const video = item.querySelector('video');
|
|
if (video) {
|
|
video.pause();
|
|
video.currentTime = 0;
|
|
}
|
|
});
|
|
|
|
// Show current content
|
|
const currentItem = this.contentItems[index];
|
|
currentItem.classList.add('active');
|
|
|
|
const video = currentItem.querySelector('video');
|
|
if (video) {
|
|
video.play();
|
|
}
|
|
|
|
// Get duration and schedule next
|
|
const duration = parseInt(currentItem.dataset.duration) * 1000;
|
|
|
|
setTimeout(() => {
|
|
this.currentIndex = (index + 1) % this.contentItems.length;
|
|
this.showContent(this.currentIndex);
|
|
}, duration);
|
|
}
|
|
|
|
checkForUpdates() {
|
|
fetch(`/api/player/${this.playerId}/content`)
|
|
.then(response => response.json())
|
|
.then(data => {
|
|
if (data.updated) {
|
|
console.log('Content updated, reloading...');
|
|
window.location.reload();
|
|
}
|
|
})
|
|
.catch(error => {
|
|
console.error('Error checking for updates:', error);
|
|
});
|
|
}
|
|
|
|
updateLastSeen() {
|
|
fetch(`/api/player/${this.playerId}/heartbeat`, {
|
|
method: 'POST'
|
|
}).catch(error => {
|
|
console.error('Error updating last seen:', error);
|
|
});
|
|
|
|
// Update display time
|
|
this.updateDisplayTime();
|
|
}
|
|
|
|
updateDisplayTime() {
|
|
const now = new Date();
|
|
document.getElementById('lastUpdate').textContent =
|
|
now.toLocaleTimeString('en-US', { hour12: false });
|
|
}
|
|
}
|
|
|
|
// Start the player when page loads
|
|
document.addEventListener('DOMContentLoaded', () => {
|
|
new DigitalSignagePlayer();
|
|
});
|
|
|
|
// Prevent right-click context menu
|
|
document.addEventListener('contextmenu', e => e.preventDefault());
|
|
|
|
// Handle keyboard shortcuts
|
|
document.addEventListener('keydown', (e) => {
|
|
if (e.key === 'F11') {
|
|
// Allow F11 for fullscreen toggle
|
|
return;
|
|
}
|
|
if (e.key === 'Escape') {
|
|
// Allow Escape to exit fullscreen
|
|
return;
|
|
}
|
|
// Prevent other keys
|
|
e.preventDefault();
|
|
});
|
|
|
|
// Auto-enter fullscreen on load
|
|
document.addEventListener('DOMContentLoaded', () => {
|
|
if (document.documentElement.requestFullscreen) {
|
|
document.documentElement.requestFullscreen().catch(err => {
|
|
console.log('Fullscreen not supported or denied');
|
|
});
|
|
}
|
|
});
|
|
</script>
|
|
</body>
|
|
</html>
|