Using local file for Web Audio API in Javascript

后端 未结 4 1443
花落未央
花落未央 2020-11-28 06:04

I\'m trying to get sound working on my iPhone game using the Web Audio API. The problem is that this app is entirely client side. I want to store my mp3s in a local folder (

4条回答
  •  余生分开走
    2020-11-28 06:47

    I had the same problem and I found this very simple solution.

    audio_file.onchange = function(){
      var files = this.files;
      var file = URL.createObjectURL(files[0]); 
                  audio_player.src = file; 
      audio_player.play();
    };
    
    

    You can test here: http://jsfiddle.net/Tv8Cm/

提交回复
热议问题