michael@0: // script.aculo.us sound.js v1.7.1_beta2, Tue May 15 15:15:45 EDT 2007
michael@0:
michael@0: // Copyright (c) 2005-2007 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)
michael@0: //
michael@0: // Based on code created by Jules Gravinese (http://www.webveteran.com/)
michael@0: //
michael@0: // script.aculo.us is freely distributable under the terms of an MIT-style license.
michael@0: // For details, see the script.aculo.us web site: http://script.aculo.us/
michael@0:
michael@0: Sound = {
michael@0: tracks: {},
michael@0: _enabled: true,
michael@0: template:
michael@0: new Template(''),
michael@0: enable: function(){
michael@0: Sound._enabled = true;
michael@0: },
michael@0: disable: function(){
michael@0: Sound._enabled = false;
michael@0: },
michael@0: play: function(url){
michael@0: if(!Sound._enabled) return;
michael@0: var options = Object.extend({
michael@0: track: 'global', url: url, replace: false
michael@0: }, arguments[1] || {});
michael@0:
michael@0: if(options.replace && this.tracks[options.track]) {
michael@0: $R(0, this.tracks[options.track].id).each(function(id){
michael@0: var sound = $('sound_'+options.track+'_'+id);
michael@0: sound.Stop && sound.Stop();
michael@0: sound.remove();
michael@0: })
michael@0: this.tracks[options.track] = null;
michael@0: }
michael@0:
michael@0: if(!this.tracks[options.track])
michael@0: this.tracks[options.track] = { id: 0 }
michael@0: else
michael@0: this.tracks[options.track].id++;
michael@0:
michael@0: options.id = this.tracks[options.track].id;
michael@0: if (Prototype.Browser.IE) {
michael@0: var sound = document.createElement('bgsound');
michael@0: sound.setAttribute('id','sound_'+options.track+'_'+options.id);
michael@0: sound.setAttribute('src',options.url);
michael@0: sound.setAttribute('loop','1');
michael@0: sound.setAttribute('autostart','true');
michael@0: $$('body')[0].appendChild(sound);
michael@0: }
michael@0: else
michael@0: new Insertion.Bottom($$('body')[0], Sound.template.evaluate(options));
michael@0: }
michael@0: };
michael@0:
michael@0: if(Prototype.Browser.Gecko && navigator.userAgent.indexOf("Win") > 0){
michael@0: if(navigator.plugins && $A(navigator.plugins).detect(function(p){ return p.name.indexOf('QuickTime') != -1 }))
michael@0: Sound.template = new Template('')
michael@0: else
michael@0: Sound.play = function(){}
michael@0: }