forked from madrobby/scriptaculous
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
script.aculo.us: Added Sound.play(url,options) in new sound.js file, …
…based on code by Jules Gravinese, used with permission. git-svn-id: http://svn.rubyonrails.org/rails/spinoffs/scriptaculous@6295 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
- Loading branch information
Showing
7 changed files
with
94 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
// Copyright (c) 2005-2007 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us) | ||
// | ||
// Based on code created by Jules Gravinese (http://www.webveteran.com/) | ||
// | ||
// script.aculo.us is freely distributable under the terms of an MIT-style license. | ||
// For details, see the script.aculo.us web site: http://script.aculo.us/ | ||
|
||
Sound = { | ||
tracks: {}, | ||
template: | ||
new Template('<embed id="sound_#{track}_#{id}" src="#{url}" loop="false" autostart="true" hidden="true"/>'), | ||
play: function(url){ | ||
var options = Object.extend({ | ||
track: 'global', url: url, replace: false | ||
}, arguments[1] || {}); | ||
|
||
if(options.replace && this.tracks[options.track]) { | ||
$R(0, this.tracks[options.track].id).each(function(id){ | ||
var sound = $('sound_'+options.track+'_'+id); | ||
sound.Stop && sound.Stop(); | ||
sound.remove(); | ||
}) | ||
this.tracks[options.track] = null; | ||
} | ||
|
||
if(!this.tracks[options.track]) | ||
this.tracks[options.track] = { id: 0 } | ||
else | ||
this.tracks[options.track].id++; | ||
|
||
options.id = this.tracks[options.track].id; | ||
if (Prototype.Browser.IE) { | ||
var sound = document.createElement('bgsound'); | ||
sound.setAttribute('id','sound_'+options.track+'_'+options.id); | ||
sound.setAttribute('src',options.url); | ||
sound.setAttribute('loop','1'); | ||
sound.setAttribute('autostart','true'); | ||
$$('body')[0].appendChild(sound); | ||
} | ||
else | ||
new Insertion.Bottom($$('body')[0], Sound.template.evaluate(options)); | ||
} | ||
}; | ||
|
||
(function(){ | ||
if(Prototype.Browser.Gecko && (navigator.platform.indexOf("Win") > 0) && navigator.plugins) { | ||
var hasQuicktime = false; | ||
for (i=0; i<navigator.plugins.length; i++ ) | ||
if(navigator.plugins[i].name.indexOf("QuickTime") >= 0) hasQuicktime = true; | ||
if(!hasQuicktime) Sound.play = function(){}; | ||
} | ||
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" | ||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> | ||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> | ||
<head> | ||
<title>script.aculo.us Sound functional test file</title> | ||
<meta http-equiv="content-type" content="text/html; charset=utf-8" /> | ||
<script src="../../lib/prototype.js" type="text/javascript"></script> | ||
<script src="../../src/scriptaculous.js" type="text/javascript"></script> | ||
</head> | ||
<body> | ||
<h1>script.aculo.us Sound test file</h1> | ||
|
||
<a href="#" onclick="Sound.play('sword.mp3'); return false">play sound (parallel)</a> | ||
|
||
<a href="#" onclick="Sound.play('sword.mp3',{replace:true}); return false">play sound (overwrite)</a> | ||
|
||
</body> | ||
</html> |
Binary file not shown.