From 0b97a2a92ffedbe8bf96308c074934c23291c41b Mon Sep 17 00:00:00 2001 From: Hugo Villeneuve Date: Mon, 11 Nov 2024 22:40:08 -0500 Subject: [PATCH] menu_playlist --- .../hvmpd-manager/files/hvmpd.sh | 68 +++++++++++++++++++ 1 file changed, 68 insertions(+) diff --git a/recipes-multimedia/hvmpd-manager/files/hvmpd.sh b/recipes-multimedia/hvmpd-manager/files/hvmpd.sh index dde10c8..08eba90 100644 --- a/recipes-multimedia/hvmpd-manager/files/hvmpd.sh +++ b/recipes-multimedia/hvmpd-manager/files/hvmpd.sh @@ -113,8 +113,34 @@ key_pressed() { return ${rc} } +list_id=0 +list_count=0 +menu=0 + +PLAYLIST_DIR="/var/lib/mpd/playlists" + +playlists_get() { + files=$(ls ${PLAYLIST_DIR}/*.m3u) + + # Clear list + pl=() + + for f in ${files}; do + f=$(basename ${f} .m3u) + #log_info "f=$f" + pl+=("${f}") + done + + list_count="${#pl[@]}" + + ##log_info "count=${list_count}" + ##log_info "pl=${pl[@]}" +} + keys_manager() { while true; do + playlists_get + if key_pressed KEY_PLAYPAUSE ; then log_info "mpc toggle" @@ -125,7 +151,46 @@ keys_manager() { fi fi + if key_pressed KEY_UP ; then + menu=1 + + if [ ${list_id} -gt 0 ]; then + list_id=$((${list_id} - 1)) + fi + fi + + if key_pressed KEY_DOWN ; then + menu=1 + + list_id=$((${list_id} + 1)) + + if [ ${list_id} -ge ${list_count} ]; then + list_id=$((${list_id} - 1)) + fi + fi + + if key_pressed KEY_LEFT ; then + menu=1 + fi + + if key_pressed KEY_RIGHT ; then + menu=1 + fi + + if key_pressed KEY_ENTER ; then + menu=1 + fi + + if [ ${menu} -eq 1 ]; then + if is_mpc_playing ; then + mpc stop 1> /dev/null + + log_info "menu = ${pl[${list_id}]}" + menu=0 + fi + if is_mpc_playing ; then + menu=0 led_on log_dbg "[playing]" else @@ -139,6 +204,9 @@ keys_manager() { lcd_init +#playlists_get +#exit 1 + # Start function in the background keys_manager & -- 2.20.1