author | Anthony Ly <anthonyly.com@gmail.com> |
Mon, 19 Nov 2012 18:26:13 +0100 | |
changeset 194 | 32102edaa81b |
parent 136 | bde1974c263b |
permissions | -rw-r--r-- |
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1 |
// script.aculo.us sound.js v1.8.3, Thu Oct 08 11:23:33 +0200 2009 |
136 | 2 |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
3 |
// Copyright (c) 2005-2009 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us) |
136 | 4 |
// |
5 |
// Based on code created by Jules Gravinese (http://www.webveteran.com/) |
|
6 |
// |
|
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/ |
|
9 |
||
10 |
Sound = { |
|
11 |
tracks: {}, |
|
12 |
_enabled: true, |
|
13 |
template: |
|
14 |
new Template('<embed style="height:0" id="sound_#{track}_#{id}" src="#{url}" loop="false" autostart="true" hidden="true"/>'), |
|
15 |
enable: function(){ |
|
16 |
Sound._enabled = true; |
|
17 |
}, |
|
18 |
disable: function(){ |
|
19 |
Sound._enabled = false; |
|
20 |
}, |
|
21 |
play: function(url){ |
|
22 |
if(!Sound._enabled) return; |
|
23 |
var options = Object.extend({ |
|
24 |
track: 'global', url: url, replace: false |
|
25 |
}, arguments[1] || {}); |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
26 |
|
136 | 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(); |
|
31 |
sound.remove(); |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
32 |
}); |
136 | 33 |
this.tracks[options.track] = null; |
34 |
} |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
35 |
|
136 | 36 |
if(!this.tracks[options.track]) |
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
37 |
this.tracks[options.track] = { id: 0 }; |
136 | 38 |
else |
39 |
this.tracks[options.track].id++; |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
40 |
|
136 | 41 |
options.id = this.tracks[options.track].id; |
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
42 |
$$('body')[0].insert( |
136 | 43 |
Prototype.Browser.IE ? new Element('bgsound',{ |
44 |
id: 'sound_'+options.track+'_'+options.id, |
|
45 |
src: options.url, loop: 1, autostart: true |
|
46 |
}) : Sound.template.evaluate(options)); |
|
47 |
} |
|
48 |
}; |
|
49 |
||
50 |
if(Prototype.Browser.Gecko && navigator.userAgent.indexOf("Win") > 0){ |
|
51 |
if(navigator.plugins && $A(navigator.plugins).detect(function(p){ return p.name.indexOf('QuickTime') != -1 })) |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
52 |
Sound.template = new Template('<object id="sound_#{track}_#{id}" width="0" height="0" type="audio/mpeg" data="#{url}"/>'); |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
53 |
else if(navigator.plugins && $A(navigator.plugins).detect(function(p){ return p.name.indexOf('Windows Media') != -1 })) |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
54 |
Sound.template = new Template('<object id="sound_#{track}_#{id}" type="application/x-mplayer2" data="#{url}"></object>'); |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
55 |
else if(navigator.plugins && $A(navigator.plugins).detect(function(p){ return p.name.indexOf('RealPlayer') != -1 })) |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
56 |
Sound.template = new Template('<embed type="audio/x-pn-realaudio-plugin" style="height:0" id="sound_#{track}_#{id}" src="#{url}" loop="false" autostart="true" hidden="true"/>'); |
136 | 57 |
else |
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
58 |
Sound.play = function(){}; |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
59 |
} |