Skip to content

Instantly share code, notes, and snippets.

@tiye
Created May 27, 2012 02:11
Show Gist options
  • Select an option

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

Select an option

Save tiye/2795955 to your computer and use it in GitHub Desktop.
getUserMedia 捕获摄像头
body
background hsl(240,90%,90%)
video
background hsl(10,90%,90%)
# 这个例子在本地运行需要开启 webRTC 支持以及启用 --allow-file-access-from-files 参数
window.onload = ->
video = document.getElementById "live"
onSuccess = (stream) ->
video.src = webkitURL.createObjectURL stream
console.log 'success'
onFail = (err) ->
console.log "Unable to get video stream!"
navigator.webkitGetUserMedia {video: true, audio: true},
onSuccess, onFail
@
html
head
title webrtc
link(rel='stylesheet',href='color.css')
script(src='handle.js')
body
video(id='live',autoplay)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment