Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 30th, 2012  |  syntax: None  |  size: 0.63 KB  |  hits: 11  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. HTML 5 Audio Player and Android/iOS
  2. <input type="file" id="file" />
  3.  
  4. <script>
  5.   player = new Audio();
  6.  
  7.   function handleFileSelect(evt) {
  8.     var files = evt.target.files; // FileList object
  9.  
  10.     var reader = new FileReader();
  11.  
  12.       // Closure to capture the file information.
  13.       reader.onload = (function(theFile) {
  14.         return function(e) {
  15.            player.src = e.target.result;
  16.            player.play()            
  17.         };
  18.       })(f);
  19.  
  20.       // Read in the image file as a data URL.
  21.       reader.readAsDataURL(f);
  22.     }
  23.   }
  24. </script>
  25.  
  26. document.getElementById('file').addEventListener('change', handleFileSelect, false);