Skip to content

Instantly share code, notes, and snippets.

@tiye
Created August 9, 2012 01:34
Show Gist options
  • Select an option

  • Save tiye/3300216 to your computer and use it in GitHub Desktop.

Select an option

Save tiye/3300216 to your computer and use it in GitHub Desktop.
play a mp3 file with buzz continously (need Chrome and buzz, audio API)
<html><head><title>Player</title><script src="buzz.js"></script>
<!-- should download "buzz.js" fisrt from "http://buzz.jaysalvat.com/"-->
<script type="text/javascript">
(function() {
var timer;
window.my = new buzz.sound('xiao.mp3');
my.play().loop();
if (localStorage.timer != null) {
timer = Number(localStorage.timer);
timer += 0.2;
my.setTime(timer);
}
my.bind('timeupdate', function(e) {
timer = this.getTime();
return localStorage.timer = String(timer);
});
}).call(this);
html
head
title Player
script(src='buzz.js')
// should download "buzz.js" fisrt from "http://buzz.jaysalvat.com/"
:coffeescript
window.my = new buzz.sound 'xiao.mp3'
my.play().loop()
if localStorage.timer?
timer = Number localStorage.timer
timer += 0.2
my.setTime timer
my.bind 'timeupdate', (e) ->
timer = @.getTime()
localStorage.timer = String timer
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment