[9:21] static (extern: com.aussom.aussomscript.ACapture) extends: object
The static 'Capture' class provides access to browser media capture APIs. It wraps getUserMedia for camera and microphone access, MediaRecorder for recording audio and video, and a canvas-based photo capture helper. All capture operations require a secure context (HTTPS or localhost). Calling any method on a plain file:// URL will result in an error.
getUserMedia (bool Audio, bool Video, callback OnStream, callback OnError = null)
Requests camera and/or microphone access from the user. On success the OnStream callback receives a stream object. On failure OnError receives a string with the error message. The returned stream object is opaque; pass it to attachStream(), startRecording(), or stopStream().
Audio is a bool, true to include the microphone.Video is a bool, true to include the camera.OnStream is a callback(stream) called on success.OnError is an optional callback(errorMsg) called on failure.nullattachStream (object Stream, object VideoEl)
Attaches a MediaStream to a Video element for live preview. Call this with the stream received from getUserMedia and a Video object. The Video element will immediately show the camera feed.
Stream is the stream object from getUserMedia.VideoEl is a Video object to display the stream.nullstopStream (object Stream)
Stops all tracks in a MediaStream, releasing the camera or microphone.
Stream is the stream object from getUserMedia.nullstartRecording (object Stream, callback OnData, callback OnError = null, string MimeType = null)
Starts recording a MediaStream. Call stopRecording() when done. When recording stops, OnData is called with a buffer containing the encoded audio/video bytes. Errors are reported to OnError. Only one recording session can be active at a time.
Stream is the stream object from getUserMedia.OnData is a callback(buffer) called with the recorded bytes.OnError is an optional callback(errorMsg) called on failure.MimeType is an optional MIME type hint, e.g. "audio/webm". Leave null to let the browser choose.nullstopRecording ()
Stops the current recording session. The OnData callback registered with startRecording() is called asynchronously with the recorded data. Returns an exception if no recording is in progress.
nullcapturePhoto (object VideoEl, int Width = 0, int Height = 0)
Captures a single photo from a live Video element. Draws the current video frame to a hidden canvas and returns the raw RGBA pixel data as a buffer. The buffer has Width * Height * 4 bytes (R, G, B, A per pixel). Returns an exception if the video has no frame yet (stream not active).
VideoEl is a Video object displaying a live camera stream.Width is the output width in pixels. 0 uses the video natural size.Height is the output height in pixels. 0 uses the video natural size.A buffer with raw RGBA pixel data.encodeBuffer (object Buf, int Width, int Height, string MimeType)
Encodes raw RGBA pixel data (from capturePhoto or Context2D.getImageData) as an image data URL. Use the returned string to set an Img.setSrc() or trigger a download.
Buf is a buffer with raw RGBA data (Width * Height * 4 bytes).Width is the image width in pixels.Height is the image height in pixels.MimeType is "image/jpeg" or "image/png".A string with the data URL.