1 // script.aculo.us sound.js v1.7.1_beta3, Fri May 25 17:19:41 +0200 2007
3 // Copyright (c) 2005-2007 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)
5 // Based on code created by Jules Gravinese (http://www.webveteran.com/)
7 // script.aculo.us is freely distributable under the terms of an MIT-style license.
8 // For details, see the script.aculo.us web site: http://script.aculo.us/
14 new Template('<embed style="height:0" id="sound_#{track}_#{id}" src="#{url}" loop="false" autostart="true" hidden="true"/>'),
16 Sound._enabled = true;
19 Sound._enabled = false;
22 if(!Sound._enabled) return;
23 var options = Object.extend({
24 track: 'global', url: url, replace: false
25 }, arguments[1] || {});
27 if(options.replace && this.tracks[options.track]) {
28 $R(0, this.tracks[options.track].id).each(function(id){
29 var sound = $('sound_'+options.track+'_'+id);
30 sound.Stop && sound.Stop();
33 this.tracks[options.track] = null;
36 if(!this.tracks[options.track])
37 this.tracks[options.track] = { id: 0 }
39 this.tracks[options.track].id++;
41 options.id = this.tracks[options.track].id;
42 if (Prototype.Browser.IE) {
43 var sound = document.createElement('bgsound');
44 sound.setAttribute('id','sound_'+options.track+'_'+options.id);
45 sound.setAttribute('src',options.url);
46 sound.setAttribute('loop','1');
47 sound.setAttribute('autostart','true');
48 $$('body')[0].appendChild(sound);
51 new Insertion.Bottom($$('body')[0], Sound.template.evaluate(options));
55 if(Prototype.Browser.Gecko && navigator.userAgent.indexOf("Win") > 0){
56 if(navigator.plugins && $A(navigator.plugins).detect(function(p){ return p.name.indexOf('QuickTime') != -1 }))
57 Sound.template = new Template('<object id="sound_#{track}_#{id}" width="0" height="0" type="audio/mpeg" data="#{url}"/>')
59 Sound.play = function(){}