Skip to content

Instantly share code, notes, and snippets.

@mattandrews
Created December 10, 2015 16:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mattandrews/9f79cb708138893414ae to your computer and use it in GitHub Desktop.
Save mattandrews/9f79cb708138893414ae to your computer and use it in GitHub Desktop.
Example usage of Web Audio API
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