17
12

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Web Audio APIでmp3を再生するだけ

Posted at

だいたい何処に書かれているサンプルソースも以下のような感じ。

var context = new AudioContext();
var buffer = null;
var source = context.createBufferSource();

var request = new XMLHttpRequest();
request.open('GET', 'xxx.mp3', true);
request.responseType = 'arraybuffer';
request.send();

request.onload = function () {
  var res = request.response;
  context.decodeAudioData(res, function (buf) {
    source.buffer = buf;
  });
};

source.connect(context.destination);
source.start(0);

実際に動作した。

createBufferSource()decodeAudioData()が何なのかはまだ理解してないけど、

ここが詳しそうだったので調べる。

17
12
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
17
12

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?