raw
mp-wp_genesis           1 // script.aculo.us sound.js v1.8.0, Tue Nov 06 15:01:40 +0300 2007
mp-wp_genesis 2
mp-wp_genesis 3 // Copyright (c) 2005-2007 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)
mp-wp_genesis 4 //
mp-wp_genesis 5 // Based on code created by Jules Gravinese (http://www.webveteran.com/)
mp-wp_genesis 6 //
mp-wp_genesis 7 // script.aculo.us is freely distributable under the terms of an MIT-style license.
mp-wp_genesis 8 // For details, see the script.aculo.us web site: http://script.aculo.us/
mp-wp_genesis 9
mp-wp_genesis 10 Sound = {
mp-wp_genesis 11 tracks: {},
mp-wp_genesis 12 _enabled: true,
mp-wp_genesis 13 template:
mp-wp_genesis 14 new Template('<embed style="height:0" id="sound_#{track}_#{id}" src="#{url}" loop="false" autostart="true" hidden="true"/>'),
mp-wp_genesis 15 enable: function(){
mp-wp_genesis 16 Sound._enabled = true;
mp-wp_genesis 17 },
mp-wp_genesis 18 disable: function(){
mp-wp_genesis 19 Sound._enabled = false;
mp-wp_genesis 20 },
mp-wp_genesis 21 play: function(url){
mp-wp_genesis 22 if(!Sound._enabled) return;
mp-wp_genesis 23 var options = Object.extend({
mp-wp_genesis 24 track: 'global', url: url, replace: false
mp-wp_genesis 25 }, arguments[1] || {});
mp-wp_genesis 26
mp-wp_genesis 27 if(options.replace && this.tracks[options.track]) {
mp-wp_genesis 28 $R(0, this.tracks[options.track].id).each(function(id){
mp-wp_genesis 29 var sound = $('sound_'+options.track+'_'+id);
mp-wp_genesis 30 sound.Stop && sound.Stop();
mp-wp_genesis 31 sound.remove();
mp-wp_genesis 32 })
mp-wp_genesis 33 this.tracks[options.track] = null;
mp-wp_genesis 34 }
mp-wp_genesis 35
mp-wp_genesis 36 if(!this.tracks[options.track])
mp-wp_genesis 37 this.tracks[options.track] = { id: 0 }
mp-wp_genesis 38 else
mp-wp_genesis 39 this.tracks[options.track].id++;
mp-wp_genesis 40
mp-wp_genesis 41 options.id = this.tracks[options.track].id;
mp-wp_genesis 42 $$('body')[0].insert(
mp-wp_genesis 43 Prototype.Browser.IE ? new Element('bgsound',{
mp-wp_genesis 44 id: 'sound_'+options.track+'_'+options.id,
mp-wp_genesis 45 src: options.url, loop: 1, autostart: true
mp-wp_genesis 46 }) : Sound.template.evaluate(options));
mp-wp_genesis 47 }
mp-wp_genesis 48 };
mp-wp_genesis 49
mp-wp_genesis 50 if(Prototype.Browser.Gecko && navigator.userAgent.indexOf("Win") > 0){
mp-wp_genesis 51 if(navigator.plugins && $A(navigator.plugins).detect(function(p){ return p.name.indexOf('QuickTime') != -1 }))
mp-wp_genesis 52 Sound.template = new Template('<object id="sound_#{track}_#{id}" width="0" height="0" type="audio/mpeg" data="#{url}"/>')
mp-wp_genesis 53 else
mp-wp_genesis 54 Sound.play = function(){}
mp-wp_genesis 55 }