Created
December 10, 2015 16:01
-
-
Save mattandrews/9f79cb708138893414ae to your computer and use it in GitHub Desktop.
Example usage of Web Audio API
This file contains hidden or 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
define(['audio'], function (audio) { | |
var mp3s = { | |
'track1': 'foo/bar/1.mp3', | |
'track2': 'foo/bar/1.mp3', | |
'track3': 'foo/bar/1.mp3' | |
}; | |
audio.init(mp3s, function() { | |
// this callback will fire when all the mp3s | |
// have been preloaded and are ready to play | |
// (so perhaps a loading animation can be removed) | |
// | |
// you could then call audio.startAll(shouldMute) | |
// (which will begin all tracks simultaneously, optionally muted) | |
// | |
// or you could call audio.toggleTrack('track2') | |
// which will mute/unmute a given track | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment