简体   繁体   English

Linux / PHP / JS:如何使用浏览器脚本在服务器上播放mp3音乐?

[英]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. 一个Raspberry-Pi(Pi),带有一个“公共”音乐目录(-网站),该目录从1986年左右开始链接到我的立体声放大器。操作系统是Raspbian。

Now I have my laptop and open the music directory web site on 192.168.0.X . 现在,我有了笔记本电脑,并打开了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. 我可以使用标准html5在客户端上播放每个文件,没问题。 But I want it played on the server. 但是我希望它在服务器上播放。

Is there a PHP/JS/AJAX way to do such thing? 有没有PHP / JS / AJAX方式可以做到这一点? Maybe some shell command executed with php? 也许一些用PHP执行的shell命令? 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. 简便的解决方案将像shell_exec之类的东西来调用,但是..您在pi上,还有其他一些不错的解决方案,请查看Mopidy, https://www.mopidy.com/ ,这将使您可以控制所有音乐在pi上播放,并在您连接的任何设备上播放。 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. 我自己将它与https://github.com/jaedb/iris一起使用,为我提供了一个不错的前端,可以控制我在pi上的所有本地音乐以及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. 如果仍然需要通过服务器上自己的网页进行控制,则仍然可以使用Mopidy并通过其Api对其进行控制。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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