Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">
  <title>JS Bin</title>
</head>
<body>
</body>
</html>
 
var url = "https://archive.org/download/testmp3testfile/mpthreetest.mp3";
let createAudioElement = data => {
  // we need an <audio> and a <source> element, because that's how web audio works:
  let audio = new Audio();
  let source = document.createElement('source');
  // we know this is an mp3, so use that
  source.type = "audio/mpeg";
  let base64 = btoa(String.fromCharCode(...new Uint8Array(data)));
  source.src = `data:${source.type};base64,${base64}`;
  audio.appendChild(source);
  // And then we play it.
  audio.play();  
};
let handleMP3response = response => {
  response
    .arrayBuffer()
    .then(createAudioElement);
};
fetch(url)
.then(handleMP3response)
.catch(e => console.error(e));
Output

You can jump to the latest bin by adding /latest to your URL

Dismiss x
public
Bin info
anonymouspro
0viewers