Created
January 1, 2018 06:35
-
-
Save t2psyto/c1ab0758c1b4ce73a85dc2b45c117757 to your computer and use it in GitHub Desktop.
Brython webcam example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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