next and previous playlist

Hi all!

I plugged LIRC to volumio. And I want to configure the buttons to switch playlists (playlist next\previous).
It is clear that you need to do it via mpc command. But can’t think of a sequence of commands.

I think it would be very convenient. In advance to make playlists on the computer (rock-list, loungelist, radio?? etc).
And then IR remote just to switch without the computer. IMHO we need to make a bash script that outputs a list of playlists that identifies the current, switch on next\previous).

reply to myself

today in working time on the job wrote this code :slight_smile:

#!/bin/bash

if [ -e /tmp/mpd_playlist ] 
then 
   playlistnum=$(cat /tmp/mpd_playlist)
else
   playlistnum=0;
   echo 0 > /tmp/mpd_playlist
   mpc rm oldlist
   mpc save oldlist
fi

playlistarrays=( `mpc lsplaylists` )
playlistcount=`mpc lsplaylists | wc -w`
let playlistcount--

if [ $playlistnum -gt $playlistcount ]
then
   playlistnum=0;
fi

echo "${playlistarrays[$playlistnum]}"
mpc clear ; mpc load "${playlistarrays[$playlistnum]}" ; mpc play
let playlistnum++

echo $playlistnum > /tmp/mpd_playlist

echo $playlistnum

this bash script save current playlist and toggle next playlist.
not tested

test script.
work fine for me :slight_smile:

my IR remote from yamaha amplifier as2000 work good :slight_smile:

presset buttons for seek, button a/b/c/d/e for toggle next playlist

It’s look like interesting feature. I will try write python script with use REST API to do this. Using mpd is not correct now.

If you can write a script, please share it. Very useful function for the remote control

Yes I will. I made some changes on spotify plugin. Now try this. I already drawed Flow diagram.