Note: The question regards running a PHP script from a shell, not a browser/server setup.
This article says how to play music from a Python script. Can a PHP script run in a shell play music, for example by starting a background process? (I'm on macOS.)
I'd like to play the mp3
and m4a/alac
formats, and once the music plays I want to be able to do pausing, resuming, jumping forwards/backwards by sending signals / calling functions.
$ php script.php
Pseudo-example of script.php
:
<?php
for($t=0; $t<5; $t++) {
$id = play_song("song $t.m4a");
sleep(5);
pause_song($id);
sleep(5);
resume_song($id);
sleep(5);
stop_song($id);
sleep(5);
}
?>