Usage:
var music = audio('http://people.mozilla.org/~roc/stream-demos/music2.webm'); // should play
window.setTimeout(function () {
music.stop();
}, 50000);
Demo: http://jsfiddle.net/GYZ5b/2/
@tsaniel and @p01, thx for help
Usage:
var music = audio('http://people.mozilla.org/~roc/stream-demos/music2.webm'); // should play
window.setTimeout(function () {
music.stop();
}, 50000);
Demo: http://jsfiddle.net/GYZ5b/2/
@tsaniel and @p01, thx for help
function( | |
s // audio source | |
){ | |
return(s=new Audio(s)) // create instance, using source | |
.play(), // play | |
s // return instance for other stuff | |
} |
function(s){return(s=new Audio(s)).play(),s} |
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE | |
Version 2, December 2004 | |
Copyright (C) 2011 Mikhail Davydov <[email protected]> | |
Everyone is permitted to copy and distribute verbatim or modified | |
copies of this license document, and changing it is allowed as long | |
as the name is changed. | |
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE | |
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION | |
0. You just DO WHAT THE FUCK YOU WANT TO. |
{ | |
"name": "audio", | |
"description": "Tiny HTML5 Audio player", | |
"keywords": [ | |
"audio", | |
"player", | |
"html5" | |
] | |
} |
<!DOCTYPE html> | |
<title>Audio player</title> | |
<div>Expected value: <b>Music should be played</b></div> | |
<script> | |
var audio = function(s){return(s=new Audio(s)).play(),s} | |
audio('http://people.mozilla.org/~roc/stream-demos/music2.webm'); | |
</script> |
Duh! Nice one @tsaniel
http://people.mozilla.org/~roc/stream-demos/music2.webm is a good background music, btw :) Found it in sources of Mozilla MediaStream Processing API
Interesting. Btw, waiting for your Tiny series :)
heh, i think you've golfed this one out of usefulness!
One more byte
function(s){return(s=new Audio(s)).play(),s}