我似乎无法弄清楚如何在我的Web服务器打开的MP3文件。如果我只是HREF(下面的代码)宋它会打开它,我访问该客户端。我想即使我从另一个设备访问HTML页中的宋在web服务器上玩。
<!DOCTYPE html>
<html>
<body>
<a href="Song.mp3">Song</a>
</body>
</html>
我该如何解决这个问题?我使用的是树莓派,阿帕奇,VLC(播放MP3),感谢您的支持:d
因为我不能直接执行命令我必须创建一个脚本,反应生成的文件。
<?php
shell_exec('touch Song1.txt');
?>
song.是 :
while [ -f run.txt ]
do
if [ -f Song1.txt ];
then
cvlc --play-and-exit songs/song.mp3
rm -f Song1.txt
fi
done
尝试这个:
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