Guest User

Untitled

a guest
Jun 23rd, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var audio = {
  2.     sounds: {},
  3.  
  4.     add : function(file) {
  5.         if(typeof(file) == 'array') {
  6.             for(var i = 0; i < file.length; i++)
  7.                 this.add(file[i]);
  8.  
  9.             return;
  10.         }
  11.  
  12.         var sound = document.createElement('audio');
  13.  
  14.         sound.volume = 0.1;
  15.         sound.setAttribute('src', 'sounds/' +  file);
  16.         sound.load();
  17.  
  18.         this.sounds[file] = sound;
  19.         insertBeforeScript(sound);
  20.        
  21.         log('Add Sound: ' + file);
  22.     },
  23.     play : function(file) {
  24.         this.sounds[file].play();
  25.         log('Play Sound: ' + file);
  26.     }
  27. }
Add Comment
Please, Sign In to add comment