dom/tests/mochitest/ajax/scriptaculous/src/sound.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/dom/tests/mochitest/ajax/scriptaculous/src/sound.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,60 @@
     1.4 +// script.aculo.us sound.js v1.7.1_beta2, Tue May 15 15:15:45 EDT 2007
     1.5 +
     1.6 +// Copyright (c) 2005-2007 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)
     1.7 +//
     1.8 +// Based on code created by Jules Gravinese (http://www.webveteran.com/)
     1.9 +//
    1.10 +// script.aculo.us is freely distributable under the terms of an MIT-style license.
    1.11 +// For details, see the script.aculo.us web site: http://script.aculo.us/
    1.12 +
    1.13 +Sound = {
    1.14 +  tracks: {},
    1.15 +  _enabled: true,
    1.16 +  template:
    1.17 +    new Template('<embed style="height:0" id="sound_#{track}_#{id}" src="#{url}" loop="false" autostart="true" hidden="true"/>'),
    1.18 +  enable: function(){
    1.19 +    Sound._enabled = true;
    1.20 +  },
    1.21 +  disable: function(){
    1.22 +    Sound._enabled = false;
    1.23 +  },
    1.24 +  play: function(url){
    1.25 +    if(!Sound._enabled) return;
    1.26 +    var options = Object.extend({
    1.27 +      track: 'global', url: url, replace: false
    1.28 +    }, arguments[1] || {});
    1.29 +    
    1.30 +    if(options.replace && this.tracks[options.track]) {
    1.31 +      $R(0, this.tracks[options.track].id).each(function(id){
    1.32 +        var sound = $('sound_'+options.track+'_'+id);
    1.33 +        sound.Stop && sound.Stop();
    1.34 +        sound.remove();
    1.35 +      })
    1.36 +      this.tracks[options.track] = null;
    1.37 +    }
    1.38 +      
    1.39 +    if(!this.tracks[options.track])
    1.40 +      this.tracks[options.track] = { id: 0 }
    1.41 +    else
    1.42 +      this.tracks[options.track].id++;
    1.43 +      
    1.44 +    options.id = this.tracks[options.track].id;
    1.45 +    if (Prototype.Browser.IE) {
    1.46 +      var sound = document.createElement('bgsound');
    1.47 +      sound.setAttribute('id','sound_'+options.track+'_'+options.id);
    1.48 +      sound.setAttribute('src',options.url);
    1.49 +      sound.setAttribute('loop','1');
    1.50 +      sound.setAttribute('autostart','true');
    1.51 +      $$('body')[0].appendChild(sound);
    1.52 +    }  
    1.53 +    else
    1.54 +      new Insertion.Bottom($$('body')[0], Sound.template.evaluate(options));
    1.55 +  }
    1.56 +};
    1.57 +
    1.58 +if(Prototype.Browser.Gecko && navigator.userAgent.indexOf("Win") > 0){
    1.59 +  if(navigator.plugins && $A(navigator.plugins).detect(function(p){ return p.name.indexOf('QuickTime') != -1 }))
    1.60 +    Sound.template = new Template('<object id="sound_#{track}_#{id}" width="0" height="0" type="audio/mpeg" data="#{url}"/>')
    1.61 +  else
    1.62 +    Sound.play = function(){}
    1.63 +}

mercurial