Combine play and pause controls into one that changes depending on state
continuous-integration/drone/push Build is passing Details

This commit is contained in:
Sijmen 2023-05-01 16:25:07 +02:00
parent 700a5ad1ac
commit 38a47a4a10
Signed by: vijfhoek
GPG Key ID: DAF7821E067D9C48
3 changed files with 14 additions and 6 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 134 KiB

After

Width:  |  Height:  |  Size: 134 KiB

View File

@ -33,18 +33,21 @@ async fn get_queue(_req: tide::Request<()>) -> tide::Result {
#[derive(Template)]
#[template(path = "player.html")]
struct CurrentTemplate {
struct PlayerTemplate {
song: Option<mpdrs::Song>,
name: Option<String>,
state: mpdrs::State,
}
async fn get_player(_req: tide::Request<()>) -> tide::Result {
let mut mpd = mpd::connect()?;
let song = mpd.currentsong()?;
let state = mpd.status()?.state;
let mut template = CurrentTemplate {
let mut template = PlayerTemplate {
song: song.clone(),
name: None,
state,
};
if let Some(song) = song {

View File

@ -41,14 +41,19 @@
hx-post="/previous"
class="control material-symbols-outlined" role="button" title="Previous track"
>skip_previous</button>
<button
hx-post="/play"
class="control material-symbols-outlined" role="button" title="Play"
>play_arrow</button>
{% if state == mpdrs::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"