Search code examples
htmlapacheraspbian

Execute audio player on server when link is clicked on web page


I can't seem to figure out how to open an mp3 File on my Webserver. If I just href the Song (Code below) it opens it on the Client I am accessing it from. I want the Song to play on the Webserver even if I access the html page from another Device.

<!DOCTYPE html>
<html>
<body>
<a href="Song.mp3">Song</a>

</body>
</html>

How do I solve this? I am using a Raspberry Pie, Apache, VLC (to play mp3) Thanks for your support :D


Solution

  • Because I couldn't execute the command directly I had to create a script which reacts to created files.

    <?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