Files

72 lines
4.8 KiB
HTML

{% macro media_icon(kind) -%}
<svg width="32" height="32" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.6" aria-hidden="true" focusable="false">
{% if kind == 'image' %}
<rect x="3" y="3" width="18" height="18" rx="2"/><circle cx="8" cy="8" r="2"/><path d="m3 18 6-6 4 4 3-3 5 5"/>
{% elif kind == 'video' %}
<rect x="2" y="4" width="20" height="16" rx="2"/><path d="M6 4v16M18 4v16M2 9h4M2 15h4M18 9h4M18 15h4m-9-7 4 4-4 4z"/>
{% elif kind == 'stream' %}
<circle cx="12" cy="12" r="2"/><path d="M8 8a6 6 0 0 0 0 8m8-8a6 6 0 0 1 0 8M5 5a10 10 0 0 0 0 14M19 5a10 10 0 0 1 0 14"/>
{% else %}
<rect x="3" y="3" width="18" height="18" rx="2"/><path d="m10 8 6 4-6 4z"/>
{% endif %}
</svg>
{%- endmacro %}
<!DOCTYPE html>
<html lang="en">
<head>
<title>Play Media - Sanctuary Commander</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" href="{{ url_for('static', filename='style.css') }}">
<script src="{{ url_for('static', filename='media_library.js') }}" defer></script>
</head>
<body>
<main class="container py-3" id="mediaLibrary" data-status-url="{{ url_for('media_library.playback_status') }}">
<h1 class="text-center">Play Media</h1>
<hr>
<a class="btn btn-secondary mb-3" href="{{ url_for('home.root_route') }}">Home</a>
<div class="alert alert-info" role="status" aria-live="polite">
<strong id="playbackSelection">{% if state.blank %}Blank screen selected{% else %}Selected for playback: {{ state.selected_name }}{% if state.using_default %} (default){% endif %}{% endif %}</strong>
<p class="mb-0 mt-1">This shows the database selection, not player health. Run <code>player.py</code> on the display computer; it picks up changes within about two seconds.</p>
</div>
<p id="statusError" class="text-danger" role="status" hidden>Unable to refresh playback status. The indicator may be out of date.</p>
{% if items %}
<div class="row g-3">
{% for item in items %}
<div class="col-12 col-md-6 col-xl-4">
<article class="card h-100 {% if state.selected_id == item.media_id %}border-success border-3{% endif %}"
data-media-id="{{ item.media_id }}">
<div class="media-preview bg-light text-secondary position-relative d-flex align-items-center justify-content-center">
{{ media_icon(item.kind) }}
{% if item.preview %}
<img class="media-thumbnail" src="{{ url_for('media_library.thumbnail', media_id=item.media_id) }}"
alt="Preview of {{ item.media_name }}" loading="lazy" decoding="async">
{% endif %}
</div>
<div class="card-body d-flex flex-column">
<h2 class="h5 text-break">{{ item.media_name }}</h2>
<p class="text-capitalize">{{ media_icon(item.kind) }} <span>{{ item.kind }}</span></p>
<div class="mb-3">
<span class="badge bg-success" data-selected-badge {% if state.selected_id != item.media_id %}hidden{% endif %}>Selected</span>
<span class="badge bg-secondary" data-default-badge {% if item.media_default != 1 %}hidden{% endif %}>Default</span>
</div>
<form class="mt-auto" method="POST" action="{{ url_for('media_library.play_media', media_id=item.media_id) }}">
<button class="btn btn-primary w-100" type="submit" {% if not (item.media_uri or '').strip() %}disabled{% endif %}>
<span aria-hidden="true">&#9654;</span> Play <span class="visually-hidden">{{ item.media_name }}</span>
</button>
</form>
<a class="btn btn-outline-danger w-100 mt-2" href="{{ url_for('media_library.delete_media', media_id=item.media_id) }}">
Delete <span class="visually-hidden">{{ item.media_name }}</span>
</a>
</div>
</article>
</div>
{% endfor %}
</div>
{% else %}
<p role="status">No media yet. Upload an image or video, configure a stream, or download a YouTube video from the home page.</p>
{% endif %}
</main>
</body>
</html>