/dev/trunk

To get this branch, use:
bzr branch http://darksoft.org/webbzr/dev/trunk

« back to all changes in this revision

Viewing changes to includes/scriptaculous/sound.js

  • Committer: Suren A. Chilingaryan
  • Date: 2008-04-02 10:23:22 UTC
  • Revision ID: csa@dside.dyndns.org-20080402102322-okib92sicg2dx3o3
Initial import

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// script.aculo.us sound.js v1.8.1, Thu Jan 03 22:07:12 -0500 2008
 
2
 
 
3
// Copyright (c) 2005-2007 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)
 
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] || {});
 
26
    
 
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();
 
32
      })
 
33
      this.tracks[options.track] = null;
 
34
    }
 
35
      
 
36
    if(!this.tracks[options.track])
 
37
      this.tracks[options.track] = { id: 0 }
 
38
    else
 
39
      this.tracks[options.track].id++;
 
40
      
 
41
    options.id = this.tracks[options.track].id;
 
42
    $$('body')[0].insert( 
 
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 }))
 
52
    Sound.template = new Template('<object id="sound_#{track}_#{id}" width="0" height="0" type="audio/mpeg" data="#{url}"/>')
 
53
  else
 
54
    Sound.play = function(){}
 
55
}