Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Grant Skinner <info@gskinner.com>
- Loading branch information
Showing
44 changed files
with
2,947 additions
and
0 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
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,73 @@ | ||
body { | ||
font-family: "Times New Roman", Times, serif; | ||
font-size: 14px; | ||
background:url(../img/bg.gif) fixed; | ||
background-repeat: repeat; | ||
text-align: center; | ||
} | ||
.content { | ||
background-color: #FFF; | ||
border: 12px solid #000; | ||
margin-top: 50px; | ||
width: 600px; | ||
margin-left: auto; | ||
margin-right: auto; | ||
margin-bottom: 50px; | ||
-webkit-box-shadow: 0px 3px 16px #333; | ||
-moz-box-shadow: 0px 2px 16px #333; | ||
box-shadow: 0px 2px 16px #333; | ||
padding: 50px; | ||
} | ||
.callout { | ||
background-image: url(../img/callout_bg.gif); | ||
background-repeat: repeat; | ||
padding: 6px; | ||
color: #000; | ||
} | ||
a { | ||
color: #568; | ||
} | ||
a:hover { | ||
color: #000; | ||
} | ||
p, ul { | ||
color: #333; | ||
text-align: justify; | ||
line-height: 1.15; | ||
} | ||
ul { | ||
padding-left: 25px; | ||
} | ||
h1 { | ||
font-size: 24px; | ||
font-weight: normal; | ||
margin-top: 10px; | ||
} | ||
h3 { | ||
text-align: left; | ||
margin-bottom: -1em; | ||
font-size: 14px; | ||
color: #000; | ||
} | ||
footer p { | ||
text-align:center; | ||
margin-bottom:0px; | ||
font-size: 11px; | ||
color: #777; | ||
font-family: Arial, Helvetica, sans-serif; | ||
} | ||
p.active{ | ||
font-weight:bold; | ||
} | ||
.demoWrap{ | ||
background:url(../img/callout_bg.gif); | ||
border:1px solid #fff; | ||
border:1px solid #cccccc; | ||
width: auto; | ||
height: auto; | ||
padding: 10px; | ||
position:relative; | ||
font-family:Tahoma, Geneva, sans-serif; | ||
font-size:12px; line-height:14px; | ||
z-index:100; | ||
} |
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,301 @@ | ||
<!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"> | ||
<head> | ||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> | ||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script> | ||
<script language="javascript" src="../soundjs/SoundJS.js"></script> | ||
<script language="javascript"> | ||
|
||
/* Setup */ | ||
function init() { | ||
startLoad(); | ||
enableSet("sound", false); | ||
enableSet("instance", false); | ||
} | ||
|
||
/* Preload sounds. Will not work on iOS | ||
All Sounds are pre-populated into the library list with the (waiting) label | ||
*/ | ||
function startLoad() { | ||
enableSet("load", false); | ||
var list = [ | ||
{name:"Steal", src:["../assets/GU-StealDaisy.ogg","../assets/GU-StealDaisy.mp3"], instances:4}, | ||
{name:"Humm (MP3)", src:"../assets/Humm.mp3"}, // NOTE: mp3-only | ||
{name:"Humm (OGG)", src:"../assets/Humm.ogg"}, // NOTE: ogg-only | ||
{name:"Damage1", src:["../assets/R-Damage.mp3","../assets/R-Damage.ogg"], instances:4}, | ||
{name:"Damage2", src:["../assets/S-Damage.mp3","../assets/S-Damage.ogg"], instances:4}, | ||
{name:"Thunder", src:["../assets/Thunder1.mp3","../assets/Thunder1.ogg"], instances:2}, | ||
{name:"ToneWobble", src:["../assets/ToneWobble.mp3","../assets/ToneWobble.ogg"], instances:2}, | ||
{name:"CabinBoy", src:["../assets/U-CabinBoy3.mp3","../assets/U-CabinBoy3.ogg"], instances:2}, | ||
{name:"GameBG", src:["../assets/M-GameBG.mp3","../assets/M-GameBG.ogg"], instances:2}, | ||
{name:"Machinae Supremacy", src:["../assets/18-machinae_supremacy-lord_krutors_dominion.mp3","../assets/18-machinae_supremacy-lord_krutors_dominion.ogg"], instances:2} | ||
]; | ||
|
||
/* | ||
// For later. iOS will not preload audio, so we must pre-populate the list so audio can be played | ||
var form = $("#playControls").get(0); | ||
form.library.remove(0); | ||
for (var i=0, l=list.length; i<l; i++) { | ||
form.library.options.add(new Option(list[i].name + " (waiting)", list[i].name)); | ||
} | ||
form.library.disabled = false;*/ | ||
|
||
SoundJS.addBatch(list); | ||
|
||
SoundJS.onSoundLoadComplete = handleComplete; | ||
//SoundJS.onProgress = handleProgress; | ||
SoundJS.onLoadQueueComplete = handleAllComplete; | ||
SoundJS.onSoundEnded = handleSoundEnded; | ||
} | ||
|
||
/* Display the progress of the load */ | ||
function handleProgress(progress) { | ||
var progress = Math.round(1/progress*100) + "%" | ||
} | ||
|
||
/* When each sound completes, it is replaced in the list with an entry that shows the available instances */ | ||
function handleComplete(sound, name) { | ||
var form = $("#playControls").get(0); | ||
var library = form.library; | ||
|
||
if (library.options[0].value == "-1") { | ||
library.remove(0); | ||
} | ||
|
||
for (var i=0, l=library.options.length; i<l; i++) { | ||
var item = library.options[i]; | ||
if (item.value == name) { | ||
form.library.remove(i); | ||
break; | ||
} | ||
} | ||
form.library.options.add(new Option(name + " ("+SoundJS.getNumInstances(name)+")", name)); | ||
if (library.disabled) { library.disabled = false; } | ||
} | ||
|
||
function handleAllComplete() {} | ||
|
||
/* A reference to the selected item */ | ||
var selectedItem; | ||
|
||
/* When a library item is selected, the UI is enabled to play it */ | ||
function selectItem(select) { | ||
// Enable UI! | ||
var item = select.options[select.selectedIndex]; | ||
if (item == null) { | ||
enableSet("sound", false); | ||
selectedItem = null; | ||
} else { | ||
enableSet("sound", true); | ||
selectedItem = item.value; | ||
} | ||
} | ||
|
||
/* Plays a sound using SoundJS. | ||
The sound is added to the "nowPlaying" list while it is playing */ | ||
function playSound() { | ||
var form = $("#playControls").get(0); | ||
var field = form.interrupt; | ||
var interrupt = field.options[field.selectedIndex]; | ||
|
||
var result = SoundJS.play(selectedItem, field.value, 1, form.loop.checked); | ||
|
||
if (result >= 0) { | ||
// Remove Default | ||
form = $("#instanceControls").get(0); | ||
if (form.nowPlaying.options[0].value == "-1") { | ||
form.nowPlaying.remove(0); | ||
} | ||
|
||
var id = selectedItem+"_"+result; | ||
removeSound(id, true); | ||
|
||
// Add latest. To add at beginning like I want we have to put in an IE hack, so forget that. | ||
form.nowPlaying.options.add(new Option(selectedItem + " ("+result+")", id)); | ||
form.nowPlaying.disabled = false; | ||
} | ||
} | ||
|
||
/* Remove a sound from the "nowPlaying" list. */ | ||
function removeSound(id, resetItems) { | ||
var form = $("#instanceControls").get(0); | ||
// Remove existing if this is an override | ||
for (var i=0, l=form.nowPlaying.options.length; i<l; i++) { | ||
if (form.nowPlaying.options[i].value == id) { | ||
form.nowPlaying.remove(i); | ||
break; | ||
} | ||
} | ||
|
||
if (resetItems != true && form.nowPlaying.options.length == 0) { | ||
form.nowPlaying.options.add(new Option("-- No Audio Playing --","-1")); | ||
form.nowPlaying.disabled = true; | ||
} | ||
|
||
} | ||
|
||
/* An instance of a playing sound has been selected. | ||
The instance controls are enabled */ | ||
function selectInstance(select) { | ||
var form = $("#instanceControls").get(0); | ||
if (form.nowPlaying.selectedIndex > -1) { | ||
var item = form.nowPlaying.options[form.nowPlaying.selectedIndex]; | ||
var parts = item.value.split("_"); | ||
form.volume.value = SoundJS.getVolume(parts[0], parts[1]) * 100; | ||
enableSet("instance", true); | ||
} else { | ||
enableSet("instance", false); | ||
} | ||
} | ||
|
||
/* Stop all sounds, and clear the "nowPlaying" list. */ | ||
function stopAllSounds() { | ||
SoundJS.stop(); | ||
|
||
// Update UI | ||
var form = $("#instanceControls").get(0); | ||
while (form.nowPlaying.options.length) { form.nowPlaying.remove(0); } | ||
form.nowPlaying.options.add(new Option("-- No Audio Playing --", "-1")); | ||
form.nowPlaying.disabled = true; | ||
} | ||
|
||
/* Stop playing a specific sound instance. */ | ||
function stopSound() { | ||
// Pull selected info, and stop it. | ||
var form = $("#instanceControls").get(0); | ||
if (form.nowPlaying.disabled) { return; } | ||
if (form.nowPlaying.selectedIndex == -1) { return; } | ||
var id = form.nowPlaying.options[form.nowPlaying.selectedIndex].value; | ||
var parts = id.split("_"); | ||
|
||
SoundJS.stop(parts[0], parts[1]); | ||
removeSound(id); | ||
|
||
enableSet("instance", false); | ||
} | ||
|
||
/* A sound has completed. Remove it from the "nowPlaying" list */ | ||
function handleSoundEnded(sound, name, index) { | ||
removeSound(name + "_" + index); | ||
} | ||
|
||
/* Change the volume of a sound instance */ | ||
function changeVolume(slider) { | ||
var form = $("#instanceControls").get(0); | ||
var item = form.nowPlaying.options[form.nowPlaying.selectedIndex]; | ||
if (item == null) { return; } | ||
var parts = item.value.split("_"); | ||
SoundJS.setVolume(slider.value/100, parts[0], parts[1]); | ||
} | ||
|
||
/* Change the master volume of SoundJS */ | ||
function changeMasterVolume(slider) { | ||
SoundJS.setMasterVolume(slider.value/100); | ||
} | ||
|
||
/* Toggle the enabled property of a named set of components in a specific form */ | ||
function enableSet(name, enabled) { | ||
switch (name) { | ||
case "load": | ||
enableItems("loadForm", enabled, ["startLoad"]); | ||
break; | ||
case "sound": | ||
enableItems("playControls", enabled, ["playPause", "interrupt", "loop"]); | ||
break; | ||
case "instance": | ||
enableItems("instanceControls", enabled, ["volume", "stop"]); | ||
break; | ||
} | ||
} | ||
|
||
/* Toggle the enabled property of a number of named elements in a form */ | ||
function enableItems(formName, value, items) { | ||
var form = $("#" + formName).get(0); | ||
if (form == null) { return; } | ||
for (var i=0, l=items.length; i<l; i++) { | ||
var item = form[items[i]]; | ||
if (item == null) { continue; } | ||
item.disabled = !value; | ||
} | ||
} | ||
|
||
|
||
</script> | ||
<title>SoundJS Test Suit</title> | ||
<style> | ||
FORM { | ||
margin: 10px; | ||
text-align:left; | ||
} | ||
.select { | ||
width: 150px; | ||
height: 120px; | ||
} | ||
</style> | ||
<link href="../css/styles.css" rel="stylesheet" type="text/css" /> | ||
</head> | ||
<body align="center" onload="init()"> | ||
<div class="content"> | ||
|
||
<header> | ||
<a href="http://github.com/gskinner/EaselJS"><img style="position: fixed; top: 0; left: 0; border: 0; z-index:200;" src="https://assets0.github.com/img/6429057dfef9e98189338d22e7f6646c6694f032?repo=&url=http%3A%2F%2Fs3.amazonaws.com%2Fgithub%2Fribbons%2Fforkme_left_orange_ff7600.png&path=" alt="Fork me on GitHub"></a> | ||
<a href="../" title="SoundJS - A Javascript lIbrary for working with html5 audio"><img src="../img/logo.gif" width="240" height="120" style="margin-top:-5px;" alt="A javascript library for working with html5 audio"/></a> | ||
<h1>Test Suite</h1> | ||
<img src="../img/flourish.gif" style="margin-bottom:10px;"/> | ||
</header> | ||
<p>This test suite loads and plays a number of sounds, defined in the source. Playing sounds can be controlled, stopped, etc</p> | ||
|
||
<form id="playControls" onsubmit="return false;" class="demoWrap"> | ||
<p>Select a sound to play it. Each sound shows how many instances it can play at once.</p> | ||
<select id="library" multiple="multiple" disabled="disabled" onchange="selectItem(this)" class="select"> | ||
<option value="-1">-- No Audio Loaded --</option> | ||
</select><br /> | ||
|
||
<input id="playPause" name="playPause" type="button" value="Play" onclick="playSound()" /> | ||
<label for="interrupt">Interrupt</label> | ||
<select id="interrupt"> | ||
<option selected="selected" value="1"> | ||
Any</option> | ||
<option value="4">None</option> | ||
<option value="2">Early</option> | ||
<option value="3">Late</option> | ||
</select> | ||
<input type="checkbox" id="loop" /> | ||
<label for="loop">Loop</label><br /> | ||
|
||
<label for="masterVolume">Master Volume</label> | ||
<input id="masterVolume" type="range" min="0" max="100" onchange="changeMasterVolume(this)" value="100" /><br /> | ||
<input name="stopAll" type="button" value="Stop All Sounds" onclick="stopAllSounds()" /><br /> | ||
</form> | ||
|
||
<form id="instanceControls" onsubmit="return false;" class="demoWrap"> | ||
<p>Select a playing sound to stop it, or control its volume. When a sound completes, it is removed from this list.</p> | ||
<select id="nowPlaying" multiple="multiple" disabled="disabled" onchange="selectInstance(this)" class="select"> | ||
<option value="-1">-- No Audio Playing --</option> | ||
</select> | ||
<br /> | ||
<label for="volume">Instance Volume</label> | ||
<input id="volume" type="range" min="0" max="100" onchange="changeVolume(this)" value="100" /> | ||
<br /> | ||
<input id="stop" name="stop" type="button" value="Stop" onclick="stopSound()" /> | ||
<br /> | ||
</form> | ||
<p class="callout"><strong>examples:</strong> | ||
<a href="../examples/convolution.html">Convolution</a>, | ||
<a href="../examples/interrupt.html">Interrupt</a>, | ||
<a href="../examples/dynamicInstance.html">Dynamic Instances</a>, | ||
<a href="../examples/masterVolume.html">Master Volume</a>, | ||
<a href="../examples/game/game.html">A Game</a> , | ||
<a href="../examples/TestSuite.html">Test Suite</a> | ||
</p> | ||
<footer> | ||
<img src="../img/flourish2.gif" style="margin: 5px;"/> | ||
<p> | ||
<script> | ||
document.write("©" + new Date().getFullYear()); | ||
</script> | ||
<a href="http://gskinner.com/">gskinner.com, inc.</a> | proudly hosted by <a href="http://mediatemple.com/">Media Temple</a></p> | ||
</footer> | ||
</div> | ||
</body> | ||
</html> |
Oops, something went wrong.