View Single Post
Old 03-19-2004, 11:59 AM   #11 (permalink)
RelaX
Follower of Ner'Zhul
 
RelaX's Avatar
 
Location: Netherlands
Tell me, why do javascript developers feel a need to bunch their code together? I mean a few newlines aren't goanna make much of a difference for download time....

Anyway, I'm not a javascript person (only had some formal education in Java) but the code below should work.
Haven't tested it though, so no guarantees.

What it now does is simply performes a stop function on the sound object before playing it, this should ensure it always starts from the beginning.

I don't know if this will work on files you're not already playing though... let me know...

And copy and paste that URL of the site.

Code:
 <script language="JavaScript">
<!--
//v3.0
function MM_controlSound(x, _sndObj, sndFile) 
{ 
  var i;
  var method = ""; 
  var sndObj = eval(_sndObj);
  
  if (sndObj != null) 
  {
    if (navigator.appName == 'Netscape') 
    {
      method = "play";
    }
    else 
    
      if (window.MM_WMP == null) 
      {
        window.MM_WMP = false;
	for(i in sndObj)
	{
	  if (i == "ActiveMovie") 
	  {
	    window.MM_WMP = true; 
	    break;
	  }
	}
      }
      if (window.MM_WMP){
      {
	method = "play";
      }
      else if (sndObj.FileName)
      {
	method = "run";
      }
    } 
  }
  if (method)
  {
    eval(_sndObj+".stop()");
    eval(_sndObj+"."+method+"()");
  }
  else
  {
    window.location = sndFile;
  }
}
//-->
</script>
__________________
The most likely way for the world to be destroyed, most experts agree, is by accident. That's where we come in; we're computer professionals. We cause accidents.
- Nathaniel Borenstein
RelaX is offline  
 

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62