Playing MP3 on raspberry pi

This is exactly what I need to do. And I also need to make the webserver active to stores the mp3.
I can manage setting it up no problem. I’m very interested thanks.

Ps: does NGINX would do the job as webserver?

1 Like

I’m sure ngix would work fine.
All you need is for the webserver to present the mp3 to the app when queried.
Any webserver will do that for you

1 Like

The app I use is ‘mp3 event player’
It’s on my website under ‘apps -> unsupported apps’
I will actually support it, it’s just so old I haven’t developed anything on it for ages

Https://cobra-apps.co.uk

Andy

2 Likes

Ok, super. Thanks. I’ll go get it in a little while...

Ok, got the webserver running, installed your app, but then.... I’m lost :weary:

First, I’m not understanding the concept of parent and child in an app. And then, when I select the mp3 event player, I need to select a “speaker”. In my mind, I thought that the mp3 event player would be the “speaker”. What other speaker I need to use?

I was hoping to get the sound directly out of the raspberry pi either on the earphone plug or using the Bluetooth option. What am I missing?

I use VLCthing Again with VLC Thing and Hubitat to play TTS out of the raspberry’s audio jack.

2 Likes

Yes I read about that. But my VCL does not have the menu I saw in screen snapshots. I was kind of lost there.
The idea was great, but when I saw that the menus were so different, I assumed that they were not talking of a vcl on a raspberry pi.

Here is the rulemachine rule to let my wife know when the mail arrives in Spanish.

I’ve also set up my Daughter’s raspberry to play a chime audio file when a door opens in her house.

Ok, but I still don’t understand what VLC we are talking about. Are we talking about the VLC that comes built in to the raspberry pi? Caus I can’t find when to set up the http in that VLC.

Yes, the VLC that comes built in with the raspian os. Let me know and if I have time I can help you set it up. It may me a little painful.

Just set up Apache2 on the Pi. It is so simple a child can do it (I managed it, so that proves it :crazy_face: It's literally one line typed into the terminal window and BOOM! There it is.

sudo apt install apache2 -y

(of course do your normal updates etc prior).

Here's the official info, direct from the horse's mouth...

https://www.raspberrypi.org/documentation/remote-access/web-server/apache.md

Once done, type in http://[your_Pi_ip] and BOOM! (again sorry, its the weekend) there is the Apache page.

Then navigate in the terminal window to where this is as follows...

cd /var/www/html

Create a directory to put your mp3 files/sounds in.

sudo mkdir sounds

Set the privileges you want to enable copying your files there... Something like

sudo chmod 666 sounds

Add your sounds (I use Teamviewer which is absolutely awesome and yet absolutely free and includes the file transfer functionality, with drag & drop) and reference them in your Rule Machine rules as....

http://[your_Pi_ip]/sounds/zombie_eating_brains.mp3

(as an example, which I use as one of my door bell sounds ha ha ha).

It's completely reliable and very fast.
Enjoy!

If I'm understanding correctly, I think you're talking about playing the mp3 through some kind of network speaker that Hubitat can play to? I think the OP's issue is that he wants the Pi to play the mp3 out of its own speaker.

Lol. I think I confused everybody here. My English and my knowledge in the HE and pi are not so high and this might be part of the reason.

But I understand that we have 3 things going in this thread:

  1. TTS. I had gave up using local TTS because the sound was too robotic for my taste. But then, @JBrown brought back the idea of the tts with the VLC thing. I had read about it and thought I didn’t have the right VLC for this. But now i know that it seems that I had the right one. Just don’t know where to set the HTML. But the tts is not my first choice any more. I really have some dought on the quality of the voice we can get locally.

  2. @Cobra offers an app to play mp3 but required me to set up webserver. So I query on webserver. And I already installed a webserver and it is up and running. Perfect.

  3. Then the app from Cobra I don’t understand how it should be working. This is the point I am at right now. The speaker list is empty

To clarify my needs.... I just want to have a speaker :speaker: (literally just a speaker) connected on the pi’s audio port to play a mp3 like “the door is open” whenever someone opens the door. And all this totally local (without internet). The HE is already talking to the pi for influxdb and Grafana.

That part I can do. But where do you enter the

http://[your_Pi_ip]/sounds/zombie_eating_brains.mp3

In HE?

Yes, in a rule to trigger the playback of your file to a device. For example, a Nest Mini. Set up a rule and use Custom Action to tell it to play the track (your mp3 file located on your Pi). Like this example which uses randomise to play different dog and zombie sounds when the front door motion detector gets triggered) ... :crazy_face:

Yes, but your Nest Mini is what give you the selection that I don’t have. If I create a virtual device “sono player” then I see the play track option. That also opens up the “speaker” option of @Cobra app.
The way I understand it is that I need a device driver that would represent the pi as a music device or something like that.

Ok ok i think I get it. The vcl thing is the missing puzzle. I’m setting it all up now.... I cross my fingers.

Oh sure, sorry, if you just wanna play sounds on your Pi through your TV. I need to learn to read the whole thread :cry:

ok, I got it partially working. In the VCL things driver, if I use the PlayTrack button, it works fine. But in a Notifier, when I enter the same mp3 file under Music device, I get an error in the Log.

groovy.lang.MissingMethodException: No signature of method: user_driver_statusbits_VLC_Thing_519.playTrack() is applicable for argument types: (java.lang.String, java.lang.Long) values: [Music/arrive.mp3, 50]
Possible solutions: playTrack(java.lang.Object), nextTrack() (playTrack)

I tried to insert several debug trace in the driver, but I cant seem to catch this.

Ok, this VCL thing need some work. It take way too much power on both, the HE and the pi.
I see that I’m not the only one with this kind of problem.
I don’t see why it has to poll the webserver every minute. May be to keep it alive? But still.... too heavy on the traffic. Sometime, it takes several seconds before the keystrokes appears on the pi while this thing is running.

And as for your app @Cobra I don’t quit understand the relation with a webserver. Your app triggers an mp3 to be sent to a music device. Nothing related to a webserver the way I see this. Am I missing something?