Reputation: 111
(I'm french so sorry for potential language errors)
I'm trying to launch the auto-airplay script (https://code.google.com/p/open-airplay/source/browse/trunk/PHP/airplay.php?r=20) with the exec() function on my website. (The scripts goal is to send picture from pc to the airplay compatible device to appear it on the screen)
It's work well but the picture disapear after few second. Initially, the script waiting for user action with the function:
echo 'Press return to quit';
fgets(STDIN);
And close the script.
Can we force the execution of the script to one precise duration ? Or closing the script with another command in php ?
Thank you for your help,
Upvotes: 1
Views: 163
Reputation: 4431
Replace the fgets(STDIN);
with a simple sleep(10);
will do as if someone waited for 10 seconds before typing something and exit the script.
[edit] from the question asked in the comment
$options = getopt("t::"); // Read for an optional value "-t" from the CLI
if (array_key_exists('t', $options)) {
sleep((int) $options['t']);
}
else {
sleep(10); //Default value
}
Upvotes: 1