public
Last active — forked from 140bytes/LICENSE.txt

Photo Booth (140byt.es)

  • Download Gist
LICENSE.txt
1 2 3 4 5 6 7 8 9 10 11 12 13
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
 
Copyright (C) 2012 Sindre Sorhus <http://sindresorhus.com>
 
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.
README.md
Markdown

Photo Booth (140byt.es)

109 bytes

Currently requires Chrome Canary

Working prefixed version (121 bytes):

Just copy paste into Dev Tools in Chrome Canary and hit enter:

!function f(a){a?document.write('<video src='+webkitURL.createObjectURL(a)+'>'):navigator.webkitGetUserMedia({video:1},f)}()

screenshot

annotated.js
JavaScript
1 2 3 4 5
function f(a){
a?
document.write('<video src='+URL.createObjectURL(a)+'>'):
navigator.getUserMedia({video:1},f)
}
index.js
JavaScript
1
function f(a){a?document.write('<video src='+URL.createObjectURL(a)+'>'):navigator.getUserMedia({video:1},f)}
package.json
JSON
1 2 3 4 5 6 7 8 9 10 11 12
{
"name": "photoBooth",
"description": "Photo Booth with JS",
"keywords": [
"photo",
"camera",
"webcam",
"getusermedia",
"html",
"webrtc"
]
}
test.html
HTML
1 2 3
<script>
!function f(a){a?document.write('<video src='+webkitURL.createObjectURL(a)+'>'):navigator.webkitGetUserMedia({video:1},f)}()
</script>

Great Scott! That's a fun idea and splendid use of the new usermedia-API.

Save some bytes:
function f(a){a?document.body.innerHTML='<video src='+webkitURL.createObjectURL(a)+'>':navigator.webkitGetUserMedia({video:1},f)}

@tsaniel amazing! I would never have thought of doing that :)

This effectively shrunk the unprefixed one down to 117 bytes and the prefixed one to 129 bytes.

In this case there is no need to close the tag. Your browser will fix the invalid syntax:

Save 4 bytes:

function f(a){a?document.body.innerHTML='<video src='+webkitURL.createObjectURL(a):navigator.webkitGetUserMedia({video:1},f)}

@aemkei Didn't work

Your right: My fault! Sorry!

But how about document.write to get it down to 121 bytes?:

function f(a){a?document.write('<video src='+webkitURL.createObjectURL(a)+'>'):navigator.webkitGetUserMedia({video:1},f)}

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.