Combine play and pause controls into one that changes depending on state
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
700a5ad1ac
commit
38a47a4a10
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 |
|
@ -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 {
|
||||
|
|
|
@ -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"
|
||||
|
|
Loading…
Reference in a new issue