Skip to content

Instantly share code, notes, and snippets.

@egonelbre
egonelbre / gist:3437746
Created August 23, 2012 15:27
State Machine
function Machine(first, $){
var cur = {}, next = $[first];
var self = {
go : function(to){ next = next ? next : ($[to] || $.undefined); },
trigger : function(event){ var t = cur.tx && cur.tx[event]; t && self.go(t); }
};
return function(){
if(next){
cur.exit && cur.exit.call(self);
cur = next; next = undefined;
@jsantell
jsantell / safariWebAudioBug.html
Created August 5, 2012 15:16
Web Audio API, proc audio / media element source Safari bug
<!DOCTYPE html>
<html>
<head>
<title>Web Audio API Test</title>
<style>#data{ color: #ff0077; font-weight: bold;}</style>
</head>
<body>
<h1>Processing audio from Media Element Source</h1>
<h2>Works in Chrome, fails in Safari</h2>
<audio controls="controls">
@westonruter
westonruter / canPlayAudioMP3.js
Created December 10, 2009 07:13
HTML5 MP3 Audio detection
/**
* Detect if the browser can play MP3 audio using native HTML5 Audio.
* Invokes the callack function with first parameter is the boolean success
* value; if that value is false, a second error parameter is passed. This error
* is either HTMLMediaError or some other DOMException or Error object.
* Note the callback is likely to be invoked asynchronously!
* @param {function(boolean, Object|undefined)} callback
*/
function canPlayAudioMP3(callback){
try {