我似乎无法弄清楚如何在Web服务器上打开mp3文件。 如果我只是对歌曲(下面的代码)进行href操作,它将在我从中访问它的客户端上将其打开。 我想要的歌曲,以在Web服务器上玩,即使我从另一个设备访问HTML网页。
<!DOCTYPE html>
<html>
<body>
<a href="Song.mp3">Song</a>
</body>
</html>
我该如何解决? 我使用的是树莓派,阿帕奇,VLC(播放MP3) 感谢您的支持:D
答案 0 :(得分:1)
尝试一下:
index.html:
<a href="/script.php">Song</a>
script.php:
<?php
exec('export DISPLAY=:0; cvlc songs/Song1.mp3');
?>
编辑:
使用inotifywait
的解决方案可以降低CPU消耗:
Php:
<?php
shell_exec('cat Song1.txt');
?>
重击:
touch Song1.txt
while [ -f run.txt ]
do
inotifywait --event=close_nowrite Song1.txt
cvlc --play-and-exit songs/song.mp3
done
答案 1 :(得分:1)
由于我不能直接执行指令I必须创建一个脚本,起反应对所创建的文件。
<?php
shell_exec('touch Song1.txt');
?>
Song.sh:
while [ -f run.txt ]
do
if [ -f Song1.txt ];
then
cvlc --play-and-exit songs/song.mp3
rm -f Song1.txt
fi
done