Hello
after few month i can now read cd audio from volumio by using mdp. I use a basic cd player connected by usb on a raspberry pi
we need install some package
apt-get update
apt-get install eject cdparanioa cdde inotify-tools
eject : manage cd ejection (i don’t have an eject button on the player i’ll use webinterface)
cdparanoia : to count tracks on cd
cdde: to detect cd insertion
inotify-tools: to change file right on cd after insertion
Mpd in Volumio is already compiled with cd support (Thanks) but we must activate it in mpd.conf
nano /etc/mpd.conf
after this
input {
plugin "curl"
}
add
input {
plugin "cdio_paranoia"
}
and restart mpd
/etc/init.d/mpd restart
I assume for this guide that your cdrom is detected on /dev/sr0.
We must create a script witch add cd tracks into mpd playlist
in /home/volumio create the script : “addcdaudio.sh”
[code]#!/bin/bash
#allow access to cdrom
chmod 644 /dev/sr0
#count with cdparanoia the tracks
tracks=$(cdparanoia -sQ |& grep -P “^\s+\d+.” | wc -l)
#add each track to mpd playlist
for ((i=1; i<=$tracks; i++)); do
mpc add cdda:///$i
done[/code]
note: you can add the whole cd by using “mpc add cdda:///” but you’ll not be able to change tracks that’s why we must count the tracks and add them individually. After cdda command you need to add 3 “/” instead of 2 because mpc remove one without reason
Rights on cdrom must be set each time yon insert a new one so we use cdde
log as volumio and launch cdde
su volumio
cdde
cdde create a file into /home/volumio/.cdde.xml
We must edit it
nano /home/volumio/.cdde.xml
change the audio command with this
<audio command="touch /home/volumio/.cdrom/cdde ; sleep 2s ; rm /home/volumio/.cdrom/cdde"/>
you must check the drive path too:
<drive path="/dev/sr0">
create folder /home/volumio/.cdrom/
As cdde can’t change right on cdrom we create a file into this folder witch be watch by inotify-tools
Create inotify-cdrom file into /home/volumio/bin
[code]#!/bin/sh
BEGIN INIT INFO
Provides: inotify-cdrom
Required-Start: $all
Required-Stop: $all
Default-Start: 2 3 4 5
Default-Stop: 0 1
Short-Description: Start daemon at boot time
Description: Enable service provided by daemon.
END INIT INFO
CONFIGURATION
DOSSIER_SURVEILLE=/home/volumio/.cdrom
MAIN
inotifywait -m --format ‘%w%f’ -e create $DOSSIER_SURVEILLE | while read LINE
do
chmod 644 /dev/sr0
done
[/code]
we must activate this at startup
nano /etc/crontab
add
@reboot root /home/volumio/bin/inotify-cdrom
@reboot volumio cdde -c /home/volumio/.cdde.xml -r
Cron is disable in volumio you must edit the script orion_optimize.sh
nano /var/www/command/orion_optimize.sh
add a # before killall -9 cron
add www-data to cdrom group
usermod -aG cdrom www-data
Now you must be able to add cdaudio into mpd by running the addcdaudio.sh script.
The tracks must appear into the playlist and you can play them
To eject the cdrom you must use
eject /dev/sr0
In order to use it with the regular web interface me must customize some files
first in /var/www create cdaudio.php
[code]<?php
// common include
include(‘inc/connection.php’);
include(‘inc/player_lib.php’);
playerSession(‘open’,$db,’’,’’);
playerSession(‘unlock’,$db,’’,’’);
?>
<?php
if (isset($_POST['syscmd'])){
switch ($_POST['syscmd']) {
case 'eject':
$cmd = 'eject /dev/sr0';
sysCmd($cmd);
session_start();
$_SESSION['w_active'] = 1;
// set UI notify
$_SESSION['notify']['title'] = 'EJECT';
$_SESSION['notify']['msg'] = 'Ejecting cd...';
// unlock session file
playerSession('unlock');
break;
case 'addcd':
$cmdadd = '/var/www/command/addcdaudio.sh';
sysCmd($cmdadd);
session_start();;
// set UI notify
$_SESSION['notify']['msg'] = 'Adding CD Audio...';
// unlock session file
playerSession('unlock');
break;
case 'addplaycd':
$cmdadd = '/var/www/command/addcdaudio.sh';
sysCmd($cmdadd);
session_start();
sendMpdCommand($mpd,'play');
// set UI notify
$_SESSION['notify']['msg'] = 'Adding CD Audio...';
// unlock session file
playerSession('unlock');
break;
case 'addreplacecd':
sendMpdCommand($mpd,'clear');
$cmdadd = '/var/www/command/addcdaudio.sh';
sysCmd($cmdadd);
session_start();
sendMpdCommand($mpd,'play');
// set UI notify
$_SESSION['notify']['msg'] = 'Adding CD Audio...';
// unlock session file
playerSession('unlock');
break;
}
}
header('Location: /index.php');
?>
[/code]
I’ve be unable to add entry into the browser tab so i change the menu.
edit /var/www/_header.php
after
<li class="<?php ami('sources'); ?>"><a href="sources.php"><i class="fa fa-folder-open sx"></i> Library</a></li>
add
<li><a href="#cdaudio-modal" data-toggle="modal"><i class="fa fa-dot-circle-o sx"></i> CD Audio</a></li>
edit /var/www/_footer.php
Before
[code]
[/code]
add
[code]
×
Manage CD Audio
Add
Add and Play
Add, replace and play
Eject
Cancel
[/code]
I hope i didn’t forgot something maybe some user and files rights must be set but i’ve test so many configurations…