Playing CDs like in the old days

The CD drive is now integrated as a third Klipspringer input source (besides the FLAC file library and the radio channels). Very simple in terms of code, but it came with lots of little annoying problems that needed fixing, and it’s cool to be able to play physical CDs and have Klipspringer control it using an actual CD player remote control, as if it was an old-style CD player rather than an Asus CD/DVD drive connected to the computer.

cd-play-remote.jpeg

I haven’t used an actual CD or DVD player since I bought a new TV and found that it had no SCART port where I could connect my old Pioneer DV-525. To replace the Pioneer, I got that little Asus drive that I can connect, when I want to use it, to the NUC that my Klipspringer hub runs on (and which is connected to the TV via HDMI), and I set up VLC to play DVDs in a way that other family members can handle. It’s possible to use VLC directly for audio CDs as well of course, but since I wanted to integrate that in Klipspringer, I wrote a little module that starts and controls VLC via the RC interface. I also switched to using VLC instead of MPlayer for radio channel streams, not to be dependent on unnecessarily many external pieces of software.

VLC usage quirks

A number of things were annoying in using VLC. One was that when my daughters watch DVDs via the VLC GUI, the output volume tends to get changed, and VLC maintains that volume when it’s started from Klipspringer. It should be possible to set the volume, either via a CLI option or the RC interface, back to 100 percent (or level 256, which is what RC calls it), but the CLI option didn’t work at all, and when I set the volume for the running process using the RC interface, it sometimes got unpredictably changed back when moving between CD tracks. So I settled for just using whatever volume was set in VLC, and changing it manually in a separate process when needed.

Another problem was synchronizing the status of VLC (which is retrieved with the RC commands info, status and get_time) with the web interface, due to timing problems and lack of synchronization in VLC. I settled for just renewing everything every couple of seconds.

Auto starting CDs

Traditionally, when you insert a CD into the player, it starts playing automatically, so maybe you want the system to mimic this behavior. The NUC that I connect the CD drive to runs an Ubuntu desktop, and I let that handle the auto starting. First this script, which in my installation is ~/klipspringer/playripscripts/klipspringer-cdda.sh:

#!/usr/bin/env bash
killall -w vlc
curl '127.0.0.1:44100/choice?source=1' >/dev/null

Then a desktop app script ~/klipspringer/playripscripts/klipspringer-cdda.desktop:

[Desktop Entry]
Version=1.0
Name=Klipspringer audio CD launcher
GenericName=CD player
Comment=Play audio CDs via Klipspringer
Exec=/home/klipspringer/klipspringer/playripscripts/klipspringer-cdda.sh %U
TryExec=/home/klipspringer/klipspringer/playripscripts/klipspringer-cdda.sh
Icon=media-cdrom-audio
Terminal=false
Type=Application
Categories=AudioVideo;Player;
MimeType=x-content/audio-cdda;
Keywords=Player;Audio;

The %U on the Exec line seems like it should have no effect, but I’ve had problems before when I’ve tried removing it, so I just leave it there. I made both these files executable and put a symlink to the desktop app script in ~/.local/share/applications, which allowed me to select it for handling CD audio in the desktop settings under devices / removable media.

Update 2023: After upgrading Ubuntu and changing how some things work, I got the problem that auto starting doesn’t work if the screen saver is active. I’m sure this can be solved, but I opted to disable auto starting and starting playing with the remote instead. I don’t always want play to start directly on inserting a CD anyway.

Making the desktop ignore the remote control

I noticed before that when I pressed some buttons on the configured remote control, a 🚫 symbol appeared in the desktop. I didn’t worry about it because it worked anyway, but now that I was controlling CD playing with the remote, something in the desktop interfered that conflicted with Klipspringer’s reactions to the play/pause button, with unpredictable results. The solution was to get the desktop to ignore the remote completely. I got the name of the remote control in the list from xinput list --name-only. The name turned out to be “ITE8708 CIR transceiver”. I then created a file /usr/share/X11/xorg.conf.d/90-irremote.conf containing:

# Ignore remote control
Section "InputClass"
        Identifier "Ignore remote control as keyboard input"
        MatchProduct "ITE8708"
        Option "Ignore" "on"
EndSection

Update 2023: After updating to Ubuntu 22.04, this configuration would no longer take effect on reboot. I take it that this is because by default Wayland is used instead of Xorg, and the configuration is for Xorg. I couldn’t find any corresponding configuration for Wayland, so instead I simply disabled Wayland by setting WaylandEnable=false in /etc/gdm3/custom.conf. I also simplified the configuration a bit (what you see above is the simplified version), which may or may not have been necessary.

New version tag

The current version tag that reflects the changes covered here is v2.3.1. Now, nothing major is likely to change for a while.

Leave a comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.