Hello,
I’m very happy I found Volumio, very cool project! The only thing missing for me is random album play feature - it would be great for guys like me who like playing albums from start to end, but have huge library and would like to be surprised .
I’m a junior dev myself (work in C# though), could someone give me pointers for queue manipulation if I wanted to write some sort of plugin?
Hi, just yesterday I got around to changing my script from loading the first track of 25 random albums to loading a random track from each of the 25 random albums.
I don’t think it would pass any awards for programming… but it works.
// library2queue
function rand(max, min) {
return Math.floor(Math.random() * (+max - +min)) + min;
}
var i = 0;
var tracks = 0;
var io = require('socket.io-client');
var socket = io.connect('http://localhost:3000');
socket.emit(’stop’);
socket.emit('clearQueue');
('browseLibrary', {'uri':'albums://'});
socket.on('pushBrowseLibrary',function(data) {
item = data.navigation.lists[0].items[0];
if (item.type == 'song') {
try {
while (item.type == 'song') {
item = data.navigation.lists[0].items[i];
i++;
}
}
catch(err) {
i-- ;
tracks = rand(i, 0);
item = data.navigation.lists[0].items[tracks];
i = 0;
}
socket.emit('addToQueue', {'uri':item.uri});
} else {
var list = data.navigation.lists[0].items;
var random = rand(list.length - 1, 0);
select = list[random];
socket.emit('browseLibrary', {'uri':select.uri});
}
});
socket.on('pushQueue', function(data) {
if (data.length > 25) {
socket.emit("play",{"value":0});
socket.disconnect()
} else {
socket.emit('browseLibrary', {'uri':'albums://'});
}
});
setTimeout(function() { socket.disconnect(); }, 10000);
I use a hacky solution: my amplifier’s remote has some useless buttons, so I figured I could use these for volumio.
I read the remote with an ir reader and an arduino plugged into the old netbook running volumio.
Then I made a small bash script reading the input from the arduino and running mostly CLI commands for volumio. For the more complex tasks like playing a random album it calls a python script.
Finally I made a service starting the script with volumio.
Now my son can play his favorite album with just one button
Bash script:
#!/bin/sh
while read -r line </dev/ttyACM0; do
if [ "$line" = "5EA1F906" ]; then
# boton btanterior
volumio previous
elif [ "$line" = "5EA17986" ]; then
#boton btsiguiente
volumio next
elif [ "$line" = "5EA139C6" ]; then
#boton btplaypause
volumio toggle
elif [ "$line" = "9E616A95" ]; then
#boton stop
volumio clear
elif [ "$line" = "9E6140BF" ]; then
#boton joaquin
volumio clear
python home/fernando/joaquin.py
elif [ "$line" = "9E61F20D" ]; then
#boton disco al azar
python home/fernando/discoalazar.py
elif [ "$line" = "9E6120DF" ]; then
#boton disco boxtops
python home/fernando/joaquin_boxtops.py
fi
done
Service:
[Unit]
Description=servicio para usar los botones libres de yamaha para volumio
Arter=network.target
After=local-fs-pre.target
[Service]
Type=oneshot
User=volumio
ExecStart=/bin/bash /usr/bin/remoto.sh
[Install]
WantedBy=multi-user.target