Skip to content

Commit 7720bcc

Browse files
author
Lanny McNie
committed
Updated demos with new basePath and alternateExtensions approaches
Signed-off-by: Lanny McNie <[email protected]>
1 parent abd5bea commit 7720bcc

File tree

10 files changed

+55
-46
lines changed

10 files changed

+55
-46
lines changed

examples/Game.html

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -138,18 +138,19 @@ <h1>Sorry!</h1>
138138
// begin loading content (only sounds to load)
139139
var assetsPath = "assets/";
140140
manifest = [
141-
{id:"begin", src:"Game-Spawn.ogg|Game-Spawn.mp3"},
142-
{id:"break", src:"Game-Break.ogg|Game-Break.mp3", data:6},
143-
{id:"death", src:"Game-Death.ogg|Game-Death.mp3"},
144-
{id:"laser", src:"Game-Shot.ogg|Game-Shot.mp3", data:6},
145-
{id:"music", src:"18-machinae_supremacy-lord_krutors_dominion.ogg|18-machinae_supremacy-lord_krutors_dominion.mp3"}
141+
{id:"begin", src:"Game-Spawn.ogg"},
142+
{id:"break", src:"Game-Break.ogg", data:6},
143+
{id:"death", src:"Game-Death.ogg"},
144+
{id:"laser", src:"Game-Shot.ogg", data:6},
145+
{id:"music", src:"18-machinae_supremacy-lord_krutors_dominion.ogg"}
146146
];
147147

148-
preload = new createjs.LoadQueue();
148+
createjs.Sound.alternateExtensions = ["mp3"];
149+
preload = new createjs.LoadQueue(true, assetsPath);
149150
preload.installPlugin(createjs.Sound);
150151
preload.addEventListener("complete", doneLoading);
151152
preload.addEventListener("progress", updateLoading);
152-
preload.loadManifest(manifest, true, assetsPath);
153+
preload.loadManifest(manifest);
153154
}
154155

155156
function updateLoading(event) {

examples/JustPlay.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,10 @@ <h1>Sorry!</h1>
7272

7373
// Create a single item to load.
7474
var assetsPath = "assets/";
75-
src = assetsPath+"18-machinae_supremacy-lord_krutors_dominion.ogg|"+assetsPath+"18-machinae_supremacy-lord_krutors_dominion.mp3";
75+
src = assetsPath+"18-machinae_supremacy-lord_krutors_dominion.ogg";
7676
// NOTE the "|" character is used by Sound to separate source into distinct files, which allows you to provide multiple extensions for wider browser support
7777

78+
createjs.Sound.alternateExtensions = ["mp3"]; // add other extensions to try loading if the src file extension is not supported
7879
//createjs.Sound.onLoadComplete = playSound; // add a callback for when load is completed
7980
createjs.Sound.addEventListener("fileload", playSound); // add an event listener for when load is completed
8081
createjs.Sound.registerSound(src); // register sound, which preloads by default

examples/MediaPlayer.html

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,9 +156,10 @@ <h1>Sorry!</h1>
156156

157157
document.getElementById("loader").className = "loader";
158158
var assetPath = "assets/";
159-
var src = assetPath+"M-GameBG.ogg|"+assetPath+"M-GameBG.mp3";
159+
var src = assetPath+"M-GameBG.ogg";
160160

161-
createjs.Sound.addEventListener("fileload", createjs.proxy(handleLoadComplete,this)); // add an event listener for when load is completed
161+
createjs.Sound.alternateExtensions = ["mp3"]; // add other extensions to try loading if the src file extension is not supported
162+
createjs.Sound.addEventListener("fileload", createjs.proxy(handleLoadComplete,this)); // add an event listener for when load is completed
162163
createjs.Sound.registerSound(src, "music");
163164
}
164165

examples/MobileSafe.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,12 +95,13 @@ <h1>Sorry!</h1>
9595

9696
// Create a single item to load.
9797
var assetsPath = "assets/";
98-
this.src = assetsPath+"18-machinae_supremacy-lord_krutors_dominion.ogg|"+assetsPath+"18-machinae_supremacy-lord_krutors_dominion.mp3";
98+
this.src = assetsPath+"18-machinae_supremacy-lord_krutors_dominion.ogg";
9999
// NOTE the "|" character is used by Sound to separate source into distinct files, which allows you to provide multiple extensions for wider browser support
100100

101101
this.displayStatus.innerHTML = "Waiting for load to complete."; // let the user know what's happening
102102
// NOTE createjs.proxy is used to apply scope so we stay within the touch scope, allowing sound to play on mobile devices
103103
this.loadProxy = createjs.proxy(this.handleLoad, this);
104+
createjs.Sound.alternateExtensions = ["mp3"]; // add other extensions to try loading if the src file extension is not supported
104105
createjs.Sound.addEventListener("fileload", this.loadProxy); // add event listener for when load is completed.
105106
createjs.Sound.registerSound(this.src); // register sound, which preloads by default
106107

examples/MusicVisualizer.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ <h1>Sorry!</h1>
7575
}
7676

7777
// Web Audio only demo, so we register just the WebAudioPlugin and if that fails, display fail message
78-
if (!createjs.Sound.registerPlugin(createjs.WebAudioPlugin)) {
78+
if (!createjs.Sound.registerPlugins([createjs.WebAudioPlugin])) {
7979
document.getElementById("error").style.display = "block";
8080
return;
8181
}

examples/PreloadAndPlay.html

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ <h1>Sorry!</h1>
8181
document.getElementById("header").style.display = "none";
8282
}
8383

84-
createjs.FlashPlugin.BASE_PATH = "../src/soundjs/"; // Initialize the base path from this document to the Flash Plugin
84+
createjs.FlashPlugin.swfPath = "../src/soundjs/"; // Initialize the base path from this document to the Flash Plugin
8585
if (params.type == "flash") {
8686
createjs.Sound.registerPlugins([createjs.FlashPlugin]);
8787
} else if (params.type == "html5") {
@@ -109,14 +109,15 @@ <h1>Sorry!</h1>
109109

110110
// Create a single item to load.
111111
var assetsPath = "assets/";
112-
var item = {src:assetsPath+"18-machinae_supremacy-lord_krutors_dominion.ogg|"+assetsPath+"18-machinae_supremacy-lord_krutors_dominion.mp3", id:"music"};
112+
//var item = {src:assetsPath+"18-machinae_supremacy-lord_krutors_dominion.ogg", id:"music"};
113113
var manifest = [
114-
{id:"music", src:assetsPath+"18-machinae_supremacy-lord_krutors_dominion.ogg|"+assetsPath+"18-machinae_supremacy-lord_krutors_dominion.mp3"}
114+
{id:"music", src:assetsPath+"18-machinae_supremacy-lord_krutors_dominion.ogg"}
115115
]
116116

117117
// Instantiate a queue.
118118
queue = new createjs.LoadQueue();
119-
queue.installPlugin(createjs.Sound);
119+
createjs.Sound.alternateExtensions = ["mp3"]; // add other extensions to try loading if the src file extension is not supported
120+
queue.installPlugin(createjs.Sound);
120121
queue.addEventListener("complete", loadComplete);
121122
queue.addEventListener("fileload", fileComplete);
122123
queue.addEventListener("error",handleFileError);

examples/SoundExplosion.html

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -96,21 +96,22 @@ <h1>Sorry!</h1>
9696
// set up our manifest of assets to load
9797
var assetsPath = "assets/";
9898
var manifest = [
99-
{src:"Game-Break.ogg|Game-Break.mp3", id:"0"},
100-
{src:"Game-Spawn.ogg|Game-Spawn.mp3", id:"1"},
101-
{src:"Game-Shot.ogg|Game-Shot.mp3", id:"2"},
102-
{src:"Thunder1.ogg|Thunder1.mp3", id:"3"},
103-
{src:"Game-Death.ogg|Game-Death.mp3", id:"4"},
104-
{src:"GU-StealDaisy.ogg|GU-StealDaisy.mp3", id:"bounce", data:soundInstanceLimit}
99+
{src:"Game-Break.ogg", id:"0"},
100+
{src:"Game-Spawn.ogg", id:"1"},
101+
{src:"Game-Shot.ogg", id:"2"},
102+
{src:"Thunder1.ogg", id:"3"},
103+
{src:"Game-Death.ogg", id:"4"},
104+
{src:"GU-StealDaisy.ogg", id:"bounce", data:soundInstanceLimit}
105105
]
106106

107107
// Instantiate a queue to preload our assets
108-
queue = new createjs.LoadQueue();
108+
queue = new createjs.LoadQueue(true, assetsPath);
109+
createjs.Sound.alternateExtensions = ["mp3"]; // add other extensions to try loading if the src file extension is not supported
109110
queue.installPlugin(createjs.Sound);
110111
queue.addEventListener("complete", loadComplete);
111112
queue.addEventListener("error",handleFileError);
112113
queue.addEventListener("progress",handleProgress);
113-
queue.loadManifest(manifest, true, assetsPath);
114+
queue.loadManifest(manifest);
114115
}
115116

116117
// show progress so the user knows something is happening during preload

examples/SoundGrid.html

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -99,23 +99,24 @@ <h1>Sorry!</h1>
9999
document.getElementById("loader").className = "loader";
100100
var assetsPath = "assets/";
101101
var manifest = [
102-
{src:"Game-Break.ogg|Game-Break.mp3", id:1},
103-
{src:"Game-Spawn.ogg|Game-Spawn.mp3", id:2},
104-
{src:"Game-Shot.ogg|Game-Shot.mp3", id:3},
102+
{src:"Game-Break.ogg", id:1},
103+
{src:"Game-Spawn.ogg", id:2},
104+
{src:"Game-Shot.ogg", id:3},
105105

106-
{src:"GU-StealDaisy.ogg|GU-StealDaisy.mp3", id:4},
107-
{src:"Humm.ogg|Humm.mp3", id:5},
108-
{src:"R-Damage.ogg|R-Damage.mp3", id:6},
106+
{src:"GU-StealDaisy.ogg", id:4},
107+
{src:"Humm.ogg", id:5},
108+
{src:"R-Damage.ogg", id:6},
109109

110-
{src:"Thunder1.ogg|Thunder1.mp3", id:7},
111-
{src:"S-Damage.ogg|S-Damage.mp3", id:8},
112-
{src:"U-CabinBoy3.ogg|U-CabinBoy3.mp3", id:9},
110+
{src:"Thunder1.ogg", id:7},
111+
{src:"S-Damage.ogg", id:8},
112+
{src:"U-CabinBoy3.ogg", id:9},
113113

114-
{src:"ToneWobble.ogg|ToneWobble.mp3", id:10},
115-
{src:"Game-Death.ogg|Game-Death.mp3", id:11},
116-
{src:"Game-Break.ogg|Game-Break.mp3", id:12} //OJR would prefer a new sound rather than a copy
114+
{src:"ToneWobble.ogg", id:10},
115+
{src:"Game-Death.ogg", id:11},
116+
{src:"Game-Break.ogg", id:12} //OJR would prefer a new sound rather than a copy
117117
];
118118

119+
createjs.Sound.alternateExtensions = ["mp3"]; // add other extensions to try loading if the src file extension is not supported
119120
createjs.Sound.addEventListener("fileload", createjs.proxy(soundLoaded, this)); // add an event listener for when load is completed
120121
createjs.Sound.registerManifest(manifest, assetsPath);
121122
}

examples/SoundTween.html

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ <h1>Sorry!</h1>
8080
var volume, pan; // 2 easeljs shapes to represent these values
8181

8282
function init() {
83-
createjs.FlashPlugin.BASE_PATH = "../src/soundjs/" // Initialize the base path from this document to the Flash Plugin
83+
createjs.FlashPlugin.swfPath = "../src/soundjs/" // Initialize the base path from this document to the Flash Plugin
8484
if (params.type == "flash") {
8585
createjs.Sound.registerPlugins([createjs.FlashPlugin]);
8686
} else if (params.type == "html5") {
@@ -110,9 +110,10 @@ <h1>Sorry!</h1>
110110

111111
// Create a single item to load.
112112
var assetsPath = "assets/";
113-
src = assetsPath+"M-GameBG.ogg|"+assetsPath+"M-GameBG.mp3";
113+
src = assetsPath+"M-GameBG.ogg";
114114
// NOTE the "|" character is used by Sound to separate source into distinct files, which allows you to provide multiple extensions for wider browser support
115115

116+
createjs.Sound.alternateExtensions = ["mp3"]; // add other extensions to try loading if the src file extension is not supported
116117
createjs.Sound.addEventListener("fileload", playSound); // add an event listener for when load is completed
117118
createjs.Sound.registerSound(src); // register sound, which preloads by default
118119

examples/TestSuite.html

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ <h1>Sorry!</h1>
185185
document.getElementById("header").style.display = "none";
186186
}
187187

188-
createjs.FlashPlugin.BASE_PATH = "../src/soundjs/" // Initialize the base path from this document to the Flash Plugin
188+
createjs.FlashPlugin.swfPath = "../src/soundjs/" // Initialize the base path from this document to the Flash Plugin
189189
if (params.type == "flash") {
190190
createjs.Sound.registerPlugins([createjs.FlashPlugin]);
191191
} else if (params.type == "html5") {
@@ -325,16 +325,17 @@ <h1>Sorry!</h1>
325325

326326
var assetsPath = "./assets/";
327327
var manifest = [
328-
{id:"Music", src:"M-GameBG.mp3", data:2},
328+
{id:"Music", src:"M-GameBG.ogg", data:2},
329329
{id:"Humm (mp3)", src:"Humm.mp3"},
330-
{id:"Humm (ogg)", src:"Humm.ogg"},
331-
{id:"Thunder", src:"Thunder1.ogg|Thunder1.mp3", data:3},
332-
{id:"Tone wobble", src:"ToneWobble.ogg|ToneWobble.mp3", type:"sound", data:1},
333-
{id:"Rat Damage", src:"R-Damage.mp3", type:"sound"},
334-
{id:"Seagull Damage", src:"S-Damage.mp3", type:"sound"},
335-
{id:"Cabin Boy", src:"U-CabinBoy3.mp3", type:"sound", data:1}
330+
{id:"Humm", src:"Humm.ogg"},
331+
{id:"Thunder", src:"Thunder1.ogg", data:3},
332+
{id:"Tone wobble", src:"ToneWobble.ogg", type:"sound", data:1},
333+
{id:"Rat Damage", src:"R-Damage.ogg", type:"sound"},
334+
{id:"Seagull Damage", src:"S-Damage.ogg", type:"sound"},
335+
{id:"Cabin Boy", src:"U-CabinBoy3.ogg", type:"sound", data:1}
336336
];
337337

338+
createjs.Sound.alternateExtensions = ["mp3"]; // add other extensions to try loading if the src file extension is not supported
338339
createjs.Sound.addEventListener("fileload", createjs.proxy(addSoundToList,this)); // add an event listener for when load is completed
339340
createjs.Sound.registerManifest(manifest, assetsPath);
340341
}

0 commit comments

Comments
 (0)