Jump to content

jerryb

New Members
  • Posts

    4
  • Joined

  • Last visited

jerryb's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Well, after some research and a bit of thought, I came up with a way to make this work.... $handle = fopen("log.html", "r"); $contents = fread($handle,filesize("log.html")); fclose($handle); $strnew = strlen ($contents); $strold = $_COOKIE['strold']; if ($strnew > $strold) {?> <script> var aSound = document.createElement('audio'); aSound.setAttribute('src', '/sounds/door_chime.mp3'); aSound.play(); </script> <? setcookie("strold", $strnew); } The only problem I am having now is that this all works through a refresh code... <meta http-equiv="refresh" content="30"> This causes problems if the refresh happens during a time when the user is filling in the comment form. Any ideas on how I could possibly reload the entire page once the user submits the comments through the form submit?
  2. Thanks Guru, However, I can't figure how to get the two variables, compare them and then fire the sound file. In my example above the sound simply loops every 3 seconds.
  3. I appreciate that response, but it appears that even they are still working on the technology WEB SOCKETS THIS IS AN EXPERIMENTAL TECHNOLOGY Because this technology's specification has not stabilized, check the compatibility for the proper prefixes to use in varius browsers. Also note that the syntax and behavior of an experimental technology is subject to change in future versions of browsers as the specs change.
  4. Hello Folks! I am new here so forgive me if I do not correctly follow your protocol. I have created a live chat on my website. The chat works very well. However, I am attempting to add an 'alarm' of sorts that will indicate when someone either responds to the chat, or enters the chat. I am attempting to create a setTimeout script that repeats every three seconds. At the beginning of the script I generate the length of the chat log file, decide whether the file is larger than before, then play a sound file if the file is larger than before. The script just keeps repeating the sound file. My code is as follows... <script> (function(){ <?php $handle = fopen("log.html", "r"); $contents = fread($handle,filesize("log.html")); fclose($handle); $strnew = strlen ($contents); if ($strnew > $strold) { ?> var aSound = document.createElement('audio'); aSound.setAttribute('src', '/sounds/door_chime.mp3'); aSound.play(); <?php } $strold = $strnew; ?> setTimeout(arguments.callee, 3000); }) (); </script>
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.