Skip to content

Instantly share code, notes, and snippets.

@thewh1teagle
Created January 23, 2024 21:37
Show Gist options
  • Select an option

  • Save thewh1teagle/a9322c9b61898f1ebbe92bd037ed6e3f to your computer and use it in GitHub Desktop.

Select an option

Save thewh1teagle/a9322c9b61898f1ebbe92bd037ed6e3f to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Audio Player</title>
</head>
<body>
<h1>Audio Player</h1>
<label for="audioFile">Select Audio File:</label>
<input type="file" id="audioFile" accept="audio/*">
<audio controls id="audioPlayer">
Your browser does not support the audio element.
</audio>
<script>
document.getElementById('audioFile').addEventListener('change', function() {
var audioPlayer = document.getElementById('audioPlayer');
var audioFile = this.files[0];
if (audioFile) {
var objectURL = URL.createObjectURL(audioFile);
audioPlayer.src = objectURL;
} else {
audioPlayer.src = '';
}
});
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment