Created
April 1, 2014 02:38
-
-
Save sylae/9906668 to your computer and use it in GitHub Desktop.
Play a local base64-encoded sound using buzz
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>A test</title> | |
<script type="text/javascript" src="buzz/buzz.js"></script> | |
<script type="text/javascript"> | |
var chat = new buzz.sound(); | |
function encodeFile() { | |
var file = document.querySelector('input[type=file]').files[0]; | |
var reader = new FileReader(); | |
var string = ""; | |
reader.onloadend = function () { | |
chat = new buzz.sound(reader.result); | |
} | |
if (file) { | |
reader.readAsDataURL(file); | |
} | |
} | |
</script> | |
</head> | |
<body> | |
<h1>A test</h1> | |
<input type="file" onChange="encodeFile();" /> | |
<input type="button" onclick="chat.play();" value="Click me"/> | |
<pre>Browser data: | |
-- PLAYS: | |
-- buzz main: <script type="text/javascript">if (!buzz.isSupported()) { document.write("No"); } else { document.write("Yes"); }</script> | |
-- buzz mp3: <script type="text/javascript">if (!buzz.isMP3Supported()) { document.write("No"); } else { document.write("Yes"); }</script> | |
-- buzz wav: <script type="text/javascript">if (!buzz.isWAVSupported()) { document.write("No"); } else { document.write("Yes"); }</script> | |
-- buzz aac: <script type="text/javascript">if (!buzz.isAACSupported()) { document.write("No"); } else { document.write("Yes"); }</script> | |
-- buzz ogg: <script type="text/javascript">if (!buzz.isOGGSupported()) { document.write("No"); } else { document.write("Yes"); }</script> | |
</pre> | |
</body> | |
</html> | |
also, there's a live preview (for now) on my sandbox, until i edit it in five months for some other stupid thing:
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Shoddy as hell, but a working proof of concept