Toddlers can be their own DJ with RFID cards
This is a short Python script that reads the ID number from an NFC card and plays the corresponding folder link using the VLC media player. The script is started by a service in the background. The communication with VLC is done via telnet.
- pip install python-telnet-vlc
- pip install evdev
- in toddlerjukebox.service set the path to ToddlerJukeBox.py, RFID reader and the playlist
- cp toddlerjukebox.service /etc/systemd/system
- enable and start the service
- To enable telnet control of VLC, open VLC, go to Tools > Preferences, show "All" settings, and enable the "Telnet" interface in the "Interface" section, then set a password.
- cp vlc.service /etc/systemd/user
The script is started by the service. It waits till for VLC to start. Each RFID card has an ID that corresponds to a path in the text file that is used as a database; the IDs and the corresponding links must to be separated by semicolons. The file has to look like follows:
<ID>;<LINK>;
<ID>;stop; // to stop the play list
<ID>;shutdowm; // turn off the computer if Node-RED runs as sudo
The card reader is recognised by the operating system as a keyboard. All you need to do is open an editor and place the card on the reader. You will immediately see the ID number.