Tom-Hirschberger / MMM-MplayerRadio

An MagicMirror² module which playes m3u radio playlists with MPlayer and supports various stations to rotate through
MIT License
8 stars 0 forks source link

Play stream to different Hifiberry #22

Closed tb59427 closed 1 year ago

tb59427 commented 1 year ago

Hi Tom,

am contemplating adding this module to my magicmirror. I have a Hifiberry connected to my stereo and the Magicmirror runs on a different box (docker on synology NAS). Would it be possible (and if so, any pointers appreciated) to stream a radio station to a remote Hifiberry?

thanks for any pointers Torsten

Tom-Hirschberger commented 1 year ago

Hi, interesting question. Did not try anything like that before. Instead of calling the player in the container it might be possible to call vlc on the remote machine instead. Which docker image do you use? karsten13/magicmirror? How do you start it? Plain docker, docker-compose, portainer or something else?

You will need to configure password-less ssh authentication with a key and map the directory containing the key to the container.

I use a container environment for development and do have a Hifiberry Amp2 connected to one of my mirrors. Maybe i do have time to test it the next days.

To get the volume buttons to work you will need to configure a custom command for the MMM-Volume, too.

Tom-Hirschberger commented 1 year ago

Could not wait to try some things ;-)

The ssh approach works well in my setup. Things you need to do:

tb59427 commented 1 year ago

Hi Tom,

am using bastilimbach/docker-magicmirror - can be easily configured via Synology's gui.

cheers -tb

tb59427 commented 1 year ago

Hi (again),

will try this out in the morning - busy this evening....thanks for your kind support.

cheers Torsten

Tom-Hirschberger commented 1 year ago

The bastilimbach/docker-magicmirror does contain the ssh command but you will need to map the mirror-ssh directory to /root/.ssh instead of /home/node/.ssh.

tb59427 commented 1 year ago

Will report back here, once I had a chance to follow your guidelines...

Tom-Hirschberger commented 1 year ago

Do you know if you are using "Alsa" or "Pulseaudio" on the HifiBerry?

If you use Bullseye release of Raspberry OS you are using "Pulseaudio".

tb59427 commented 1 year ago

Dunno - uname -a says this Linux MasterLink 5.15.78-v7l #1 SMP Wed Feb 22 13:21:34 UTC 2023 armv7l GNU/Linux

Tom-Hirschberger commented 1 year ago

If you use "Pulseaudio" you can place the two scripts in the attached zip file (getVolume.bash and setVolume.bash) into the home directory (usually /home/pi) of your Hifiberry. If you setup the password-less login successfully you can then configure MMM-Volume to call the scripts instead of the local ones:

        {
            module: "MMM-Volume",
            position: "top_left", // It is meaningless. but you should set.
            config: {
                usePresetScript: null,
                getVolumeScript: `ssh pi@HIFI_BERRY_IP \"/home/pi/getVolume.bash\"`, //get 0~100
                setVolumeScript: `ssh pi@HIFI_BERRY_IP \"/home/pi/setVolume.bash #VOLUME#\"`, //set 0~100
                volumeOnStart: 50,
            }
        },

scripts.zip

Tom-Hirschberger commented 1 year ago

Could you run

cat /etc/os-release

The result should look something like:

PRETTY_NAME="Raspbian GNU/Linux 11 (bullseye)"
NAME="Raspbian GNU/Linux"
VERSION_ID="11"
VERSION="11 (bullseye)"
VERSION_CODENAME=bullseye
ID=raspbian
ID_LIKE=debian
HOME_URL="http://www.raspbian.org/"
SUPPORT_URL="http://www.raspbian.org/RaspbianForums"
BUG_REPORT_URL="http://www.raspbian.org/RaspbianBugs"
Tom-Hirschberger commented 1 year ago

By the way i would suggest to switch to the docker image karsten13/magicmirror:fat. The one of bastilimbach is pretty out-dated and karsten13 is one of the MagicMirror² maintainers. But you will need to change some directory mappings to get the other image to work.

Tom-Hirschberger commented 1 year ago

The output of uname -a looks a little bit like you are running "HiFiBerryOS". I did not try that till now. Maybe there is no vlc media player installed the audio control will not work.

Will need to check that out tomorrow but the output of cat /etc/os-release would be very helpful.

tb59427 commented 1 year ago

NAME=Buildroot VERSION=2021.11-dirty ID=buildroot VERSION_ID=2021.11 PRETTY_NAME="Buildroot 2021.11"

Tom-Hirschberger commented 1 year ago

I am pretty sure that's HiFiBerry OS. Maybe I can look at it tomorrow.

tb59427 commented 1 year ago

By the way i would suggest to switch to the docker image karsten13/magicmirror:fat. The one of bastilimbach is pretty out-dated and karsten13 is one of the MagicMirror² maintainers.

Hmm - looking at the description this would require a pi to run. I am currently running my magic mirror server on my synology NAS, though. Switching to the more current version from Karsten would mean, I had to compeletely rebuild my pi setup. That would take some time I suppose.

And yes, the system I am running is HifiberryOS.

Tom-Hirschberger commented 1 year ago

I did not try to run the image of karsten13 on my Synology but i run it on my Desktop which is a x64 Intel system. But it makes no difference at the moment.

Just checked out HifiBerry OS and installed it with spare SD card. It is a closed system which does not have any option to install a player like vlc. It provides a REST-API which can be used to control the volume and/or start/stop the player. But i do not see any chance to run a custom station or tell via REST to activate a specific station.

tb59427 commented 1 year ago

Yeah, found that,too, this morning.

Regarding the server version of karsten13 I'll try to install it once I understand the folder mapping requirements...

Tom-Hirschberger commented 1 year ago

HifiBerry OS uses mpd under the hood but i can not get the daemon to run a custom playlist.

Tom-Hirschberger commented 1 year ago

There may be a chance to control mpd with the preinstalled tool mpc

Tom-Hirschberger commented 1 year ago

I think i found a way to wrap the commands to a simple script which can be used by the module.

tb59427 commented 1 year ago

With the attempt to install karsten13 version of magicmirror I managed to kill my whole install - neither the old nor the new install now works. So - reinstalling first :-)

Tom-Hirschberger commented 1 year ago

Sh... Good luck with it.

I release a new version 0.0.11 of this module a few seconds ago which contains the wrapper for HiFiBerryOS and instructions in the Readme of how to use it.

I think the trickiest part is to setup the ssh authentication first now.

Edit: Fixed another bug. Please use latest 0.0.12 instead.

Tom-Hirschberger commented 1 year ago

I found some more (old) bugs which i want to fix. Sorry for the short distances of the releases. There will be another one in a couple of minutes cause there are problems if stations get changed to quickly and a wrapper is used.

Tom-Hirschberger commented 1 year ago

Version 0.0.13 is out now. Station changes now should be possible, too.

Tom-Hirschberger commented 1 year ago

I tried the fat image of karsten13 on my DS420+ a few minutes ago. There is one pitfall while creating the container cause the command to run needs to be specified. It can not be changed after the container has been created and needs to be npm run server.

While creating the container, after the page where network is configured there is page with "Additional options" at the end. In the "Additional Options" there is a tab called "Ausführungsbefehl" (i use the german version, do not know how Synology named it in the english one).

and mapped them to

You then can start the container and add a additional Terminal under Details to run /bin/bash. In this terminal you can run the commands to clone the modules and install them.

I needed to change the ownership of the ssh folder to the user id of the user node in the new terminal by calling:

chown -R 1000:1000 /home/node/.ssh

After this everything worked like a charm.

tb59427 commented 1 year ago

Hi Tom,

took a different route: installed all on a raspi now. Works really well - thanks for the work to integrate hifiberries. Works really well...

cheers Torsten

Tom-Hirschberger commented 1 year ago

Maybe the Pi is the better choice anyway. Resources of the NAS are very limeted except you have one of the really big ones.

Great to hear that the HiFiBerryOS integration works. I will close the ticket then.