简体   繁体   中英

Linux/PHP/JS: How to play mp3 music on the server with a browser script?

I would like to have the following setup:

A Raspberry-Pi (Pi) with a "public" music directory (-web site), which is linked to my stereo amplifier from about 1986. OS is Raspbian.

Now I have my laptop and open the music directory web site on 192.168.0.X . I press a button and THE SERVER plays the music over the amplifier.

I have all set up except the button for the server play. The music directory is on the same machine like the sound output. I can play each file on the client with standard html5, no problem. But I want it played on the server.

Is there a PHP/JS/AJAX way to do such thing? Maybe some shell command executed with php? Also, can I stop/pause the music or start a new one in the middle of the old one, and how?

Does the functionality need to be so basic? Easy solution would be calling like shell_exec or something but.. You're on a pi and there's a few other decent solutions, check out Mopidy, https://www.mopidy.com/ , this will allow you to control all the music on the pi and play it on any device you have connected. I use it myself along with https://github.com/jaedb/iris gives me a nice frontend to control all my local music on the pi and also Spotify.

If you still need to control from your own webpage on the server, you can still use mopidy and control it via it's Api.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM