mirror of
https://github.com/pyscript/pyscript.git
synced 2026-02-26 08:03:59 -05:00
Add media module tests (#2306)
* Add media Python tests * Add media js test * Remove try except blocks * Make Python tests more end-to-end * Add media Python tests * Add media js test * Remove try except blocks * Make Python tests more end-to-end * MicroPython explorations. * Fix websocket tests, so they just skip. * Fix MicroPython media tests, if no permission is given for a video device. --------- Co-authored-by: Nicholas H.Tollervey <ntoll@ntoll.org> Co-authored-by: Andrea Giammarchi <andrea.giammarchi@gmail.com>
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -31,25 +31,22 @@ class Device:
|
||||
|
||||
@classmethod
|
||||
async def load(cls, audio=False, video=True):
|
||||
"""Load the device stream."""
|
||||
options = window.Object.new()
|
||||
options.audio = audio
|
||||
"""
|
||||
Load the device stream.
|
||||
"""
|
||||
options = {}
|
||||
options["audio"] = audio
|
||||
if isinstance(video, bool):
|
||||
options.video = video
|
||||
options["video"] = video
|
||||
else:
|
||||
# TODO: Think this can be simplified but need to check it on the pyodide side
|
||||
|
||||
# TODO: this is pyodide specific. shouldn't be!
|
||||
options.video = window.Object.new()
|
||||
options["video"] = {}
|
||||
for k in video:
|
||||
setattr(options.video, k, to_js(video[k]))
|
||||
|
||||
return await window.navigator.mediaDevices.getUserMedia(options)
|
||||
options["video"][k] = video[k]
|
||||
return await window.navigator.mediaDevices.getUserMedia(to_js(options))
|
||||
|
||||
async def get_stream(self):
|
||||
key = self.kind.replace("input", "").replace("output", "")
|
||||
options = {key: {"deviceId": {"exact": self.id}}}
|
||||
|
||||
return await self.load(**options)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user