forked from ikennyfallas/atari-arcade
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplaySound.js
More file actions
36 lines (26 loc) · 902 Bytes
/
playSound.js
File metadata and controls
36 lines (26 loc) · 902 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
function preload() {
var preloader = new createjs.PreloadJS();
// SoundJS helps resolve paths, and preload audio properly
preloader.installPlugin(createjs.SoundJS);
preloader.onComplete = preloadCompleteHandler;
// Preload a whole manifest
preloader.loadManifest([
// Recommended approach
{id:"music", src:"path/to/sound.mp3"},
// Point to both an OGG and MP3
{id:"music", src:"path/to/sound.mp3|path/to/sound.ogg"},
// Preload a few channels
{id:"music", src:"path/to/sound.mp3", data:3}
]);
// Or just preload a single sound.
preloader.loadFile({id:"music", src:"path/to/sound.mp3", data:3});
}
// Play a sound instance.
function playSound() {
var instance = createjs.SoundJS.play("music");
// Control the instance using a reference
instance.pause();
instance.setVolume(0.5);
// Get notified when a sound finishes.
instance.onComplete = playbackCompleteHandler;
}