Playing CDs directly from MPD

Hello
I try since few days to read some audio cd in volumio without riping it.
I’ve found this tutorial to use fuse/gvfs to do this
mpd.wikia.com/wiki/How_to_play_an_audio_cdrom

but i have some issues
Here the step to configure your volumio:

Add gvfs support (fuse and libcdio-paranoia1 are already install)

apt-update
apt-get install gvfs*

I give right to pi or volumio user

adduser pi fuse adduser pi audio adduser pi cdrom

You must symlink the .gvfs directory into mdp/music:

cd /var/lib/mpd/music ln -s /home/<user>/.gvfs/cdda:host=sr0/CDAUDIO

After that we need to mount the cd and update mpd

dbus-launch gvfs-mount cdda://sr0 mpc update CDAUDIO

(sometimes you have to chown 655 /dev/sr0 before. You can have this error too

No such interface 'org.gtk.vfs.MountTracker' on object at path /org/gtk/vfs/mounttracker

just retry mounting)

After that we can detect a cdrom and create an automount with cdde and notify
We can play the CD in mpd adding cdda:// in the playlist.

My problem is i can’t mount the cd without using sudo or being root. When i do this the cd is mount in /.gvfs/cdda:host=sr0 (you can see wave files) but mpd can’t access it.

do you know how to allow mounting gvfs for any user?
I tried to change /etc/fuse.conf but nothing change.

Thank you

Hi Emixam,

i’m not sure… maybe

usermod -aG fuse mpd usermod -aG audio mpd usermod -aG cdrom mpd

Klaus

Hi after few month i try to solve this probleme again.
I’ve been unable to use gvfs-mount but i have a working solution witch need some development.

So, with a fresh installation of volumio 1.55 you need to install:
cdde : to detect cdrom insertion
cdparanoia : to count tracks on cd audio
eject : to ejecct cdrom

apt-get update apt-get install cdparanoia eject cdde

You must edit /etc/mdp.conf to alow mpd to use cdparanio plugin to be active

search

input { plugin "curl" }

and add after:

input { plugin "cdio_paranoia" }

Now we must add all the tracks to mpd playlist. For now i don’t have GUI for that or automatic mounting method i will use in futur cdde.

in /home/volumio create addcdaudio.sh

#!/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

If you launch this script in terminal you should see tracks added into the playlist and you can play them.

To be continued

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…

Hi Emixam,

thanks for all the work.
I’m completely new to the Pi and started by setting up Volumio at home. The USB-CD functionality is exactly what I was looking for.

So at the moment, I am still a bit overwhelmed by what needs to be done although I find your guide very detailed and can imagine trying it out.
That will take me a while though, so I wanted to leave a post here to say it would be great to have this implemented in Volumio for out of the box use.

Is there a way to enable some kind of autoplay after inserting the CD?

Thanks again and I hope this great work will find a lot of fans.
Best,
Chris

Hi Chris
I hope too this to be implemented in volumio in futurs release but not like this i think. I wait for volumio 2 and if i can propose something more integrated with volumio UI. (if i’m able to code)
The good thing is that mpd is already compile by volumio team with the appropriated plugin.

You can define an autoplay (not with the web interface) by adding “mpc play” like this:

/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
   mpc play
done[/code]

Hi, Emixam. Thanks for your instructions. I was able to add the code and make the edits you recommended, and now I can play CDs from a USB CD/DVD player. This is a major accomplishment.

I have one problem, though. When I click any of the buttons to add tracks to the playlist, the tracks are added, but they will not play. If I add the tracks via SSH and the command line running addcdaudio.sh, the tracks show up in the playlist and can be played normally. However, if I use the web interface, the tracks are added to the playlist, but I cannot select a track and clicking the play button does nothing.

Any suggestions you can offer would be appreciated!

Thanks!!

David

Hi david sorry for the delay

Maybe you can try add mpd or volumio to the cdrom group like we did for www-data:

usermod -aG cdrom www-data

be sure to have into addcdaudio.sh

#allow access to cdrom chmod 644 /dev/sr0

When you try from command line witch account do you use?

hi Emixam,

Thanks also for this - great work!

However, I have the same issue as David - I can make it work from the command line (logged in as volume account and running script using sudo) but it doesn’t work from the ‘CD Audio’ panel in the volume interface.

I did get it working on one occasion but not sure what I did - I expect it was setting permissions on /dev/sr0

I tried adding the user permissions as described but makes no difference.

Any other ideas?

Chris

Hi everyone,

I tried reproducing the results from the guide on Volumio 2RC1, but have some problems with mpd. I can add tracks, but if I try to play them, it takes a ridiculous amount of time (~10s) to buffer 10% of 8kb, then it starts playing for ~3s-4s and then starts stuttering/jittering like crazy.
To me this looks like serious buffer underrun, but I can’t find the reason why. The drive seems to be okay: drive speed of 24x should be fast enough, also 8x to prevent early spindown and if I connect it to my mac it plays flawlessly.
My next suspicion was cdparanoia, but if I comment out the input plugin part situation doesn’t change. Also if I run cdparanoia standalone it rips the track of 2:19min in 1:41min.
So right now I have no clue what’s going on and why it’s got these problems with mpd. Any ideas from the community?

I guess there have been some under-the-hood system update from RC1 to RC2, so maybe some of the performance issues have been cleared?
Any further tests since RC2+Hotfix ?

Any update?

Hi
for now on a fresh install of volumio 2 and a raspberry 1 my cheap usb cdrom play nice not delay at all.
It’s just some test from command line. I must understand how to create de web ui to make the plugin

Great news, thanks!
Can’t wait for the plugin: good luck.

My RPi1 and CD drive still refuse to work together without underflows on RC2. However I got myself a RPi3 in the meantime, maybe the extra power might solve some problems. Otherwise I will need to try another drive. Still interested in this topic, but first need to finalize my Pi1 build without the CD.

Incidentally noticed in some recent Volumio commits in gihub, reference to music_service/cd_controller and ripper.service.js in Volumio2-UI.
Hoping this denotes something is in the work to manage CD playback and even rip.

I too have exactly same problem. I have RPi2. But for me, cdparanoia itself throws errors.,

cdparanoia -A gives the below error.,
Attempting to set cdrom to full speed…
405: Option not supported by drive
CDROM speed set FAILED. Continuing anyway…

Extracting audio also fails. So, I guess either the USB DVD drive or the powered USB hub is the problem. But, I got the CDs to play using Vlc. :smiley: Vlc works flawlessly, no audio drops. But looks like there are frequent reads, the green led in the drive keeps blinking. That is fine with me considering both powered USB hub & USB DVD drive are very cheap.

Hello everyone

I’m using Volumio 2.031 and am trying to get it to play CDs via MPD. I’ve tried to follow the instructions on the first page but I assume the web interface has changed quite a lot with the 2.x release and thus I’m stuck where it says I need to edit the /var/www/command/orion_optimize.sh file as it is simply not there.

The CD drive itself seems to work (actually it’s a BD drive… uh) and cdparanoia says all is ok. I’m just not able to play the audio on it. Can anyone help me to get it to work with Volumio 2.x?

Thanks

Can you get it to play from the console via SSH?

I can play a CD using mplayer -cdrom-device /dev/sr0 cdda://
But as for Volumio…