Skip to content

Instantly share code, notes, and snippets.

@t2psyto
Created January 1, 2018 06:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save t2psyto/c1ab0758c1b4ce73a85dc2b45c117757 to your computer and use it in GitHub Desktop.
Save t2psyto/c1ab0758c1b4ce73a85dc2b45c117757 to your computer and use it in GitHub Desktop.
Brython webcam example
import browser
from browser import html, document
aa = document['main']
videotag = html.VIDEO(id='video', width='320', height='240')
aa.html = ""
aa <= videotag
from javascript import JSObject
createUrl = JSObject(window.URL.createObjectURL)
def OnSuccess(stream):
video = document['video']
video.src = createUrl(stream)
video.play()
browser.window.navigator.mediaDevices.getUserMedia(
{"video": True, "audio": False}
).then(OnSuccess)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment