empede/templates/player.html

101 lines
2.7 KiB
HTML

{# #}
<!DOCTYPE html>
<div class="current">
{% if let Some(song) = song %}
<div class="albumart">
<a href="/art?path={{ song["file"]|urlencode }}" target="_blank">
<img
src="/art?path={{ song["file"]|urlencode }}"
onload="this.style.visibility = 'visible'"
alt="Album art"
>
</a>
</div>
<div class="metadata">
{% if let Some(name) = name %}
<div class="song__name" title="Song name">{{ name }}</div>
{% endif %}
{% if let Some(artist) = song.get("Artist") %}
<div class="song__artist" title="Artist">{{ artist }}</div>
{% endif %}
</div>
{% else %}
<div class="metadata idle">
Nothing playing right now
</div>
{% endif %}
</div>
<div class="controls" hx-swap="none" hx-trigger="click,keyUp[key=='Enter']">
<button
hx-post="/previous"
class="control material-symbols-outlined" role="button" title="Previous track"
>skip_previous</button>
{% if state == "play" %}
<button
hx-post="/pause"
class="control material-symbols-outlined" role="button" title="Pause"
>pause</button>
{% else %}
<button
hx-post="/play"
class="control material-symbols-outlined" role="button" title="Play"
>play_arrow</button>
{% endif %}
<button
hx-post="/next"
class="control material-symbols-outlined" role="button" title="Next track"
>skip_next</button>
</div>
<div class="controls" hx-swap="none" hx-trigger="click,keyUp[key=='Enter']">
<button
hx-post="/consume"
class="control material-symbols-outlined {% if consume %}active{% endif %}" role="button" title="Consume"
>delete_sweep</button>
<button
hx-post="/shuffle"
class="control material-symbols-outlined {% if shuffle %}active{% endif %}" role="button" title="Shuffle"
>shuffle</button>
<button
hx-post="/repeat"
class="control material-symbols-outlined {% if repeat %}active{% endif %}" role="button" title="Repeat"
>repeat</button>
</div>
<div class="progress" style="width: {{ elapsed / duration * 100.0 }}%"></div>
<script>
{% if let Some(name) = name %}
{% if state == "play" %}
document.title = "▶ " + {{ name|json|safe }} + " - Empede";
{% else %}
document.title = "⏸ " + {{ name|json|safe }} + " - Empede";
{% endif %}
{% else %}
document.title = "Empede";
{% endif %}
{% if state == "play" %}
progressBar = document.querySelector(".nowplaying .progress");
elapsed = {{ elapsed }};
duration = {{ duration }};
if (progressInterval) {
window.clearInterval(progressInterval);
}
progressInterval = window.setInterval(() => {
elapsed += 1.0;
let progress = Math.min(elapsed / duration, 1.0);
progressBar.style.width = `${progress * 100}%`;
}, 1000);
{% endif %}
</script>