Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var audio = {
- sounds: {},
- add : function(file, autoplay) {
- if(typeof(file) == 'array') {
- for(var i = 0; i < file.length; i++)
- this.add(file[i]);
- }
- var sound = document.createElement('audio');
- if(autoplay)
- sound.autoplay = true;
- sound.setAttribute('src', 'sounds/' + file);
- sound.load();
- this.sounds[file] = sound;
- insertBeforeScript(sound);
- log('Add Sound: ' + file);
- },
- play : function(file) {
- this.sounds[file].play();
- log('Play Sound: ' + file);
- }
- }
Add Comment
Please, Sign In to add comment