Hi,
I've got a question for you.
I am wondering what is the best way to execute a audio file is. I'm building a timer script that plays a audio file when the time is up. Right now, I can only think of using HTML to embed an audio file if certain conditions are met, but if there's a better way, I would like to try it.
Come to think of it, maybe you could check my theory, and see if it's ok.
Basically, the user selects an amount of time to count (ie. 30 mins). Script gets current time and current time + amount of time selected above. Page refreshes every minute (done by a HTML redirect...if you can think of a better way, I would love to hear it), and if current time is equal or greater to end time, play the file.
Please give me your comments, suggestions, etc.
Thanks,
Sphen001
[SOLVED] Executing a file for a timer?
Moderator: General Moderators
-
Sphen001
- Forum Contributor
- Posts: 107
- Joined: Thu Mar 10, 2005 12:24 pm
- Location: Land of the Beaver
[SOLVED] Executing a file for a timer?
Last edited by Sphen001 on Tue Jul 12, 2005 9:19 pm, edited 1 time in total.
- thomas777neo
- Forum Contributor
- Posts: 214
- Joined: Mon Mar 10, 2003 6:12 am
- Location: Johannesburg,South Africa
Suggestion:
Create a text file with php or a session, with the time now + added time.
I your code do something like this:
Create a text file with php or a session, with the time now + added time.
I your code do something like this:
Code: Select all
while (true)
{
if ($_SESSION['time'] <= the time now) // check if expired
{
// play audio file
}
else
{
sleep(60); // if not sleep for 1 minute
}
}- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact:
What conditions?
I wouldn't recommend using sleep that way.
Some malicious user could do some damage with it setup like that.
Code: Select all
if ($variable == 'somevar')
{
//send header
header();
}
else
{
//deny
}I wouldn't recommend using sleep that way.
Some malicious user could do some damage with it setup like that.