Skip to content

Added ImageCapture #410

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Sep 4, 2021
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@
*/
package org.scalajs.dom.experimental.mediastream

import org.scalajs.dom.raw._

import scala.scalajs.js
import scala.scalajs.js.|
import scala.scalajs.js.annotation._
import org.scalajs.dom.raw.{DOMException, Event, EventInit, EventTarget}
import scala.scalajs.js.|

/**
* The MediaStream
Expand Down Expand Up @@ -626,3 +627,41 @@ trait MediaTrackSupportedConstraints extends js.Object {
var deviceId: js.UndefOr[Boolean] = js.undefined
var groupId: js.UndefOr[Boolean] = js.undefined
}

/**
* The ImageCapture interface of the MediaStream Image Capture API provides methods
* to enable the capture of images or photos from a camera or other photographic
* device referenced through a valid MediaStreamTrack.
*
* MDN
*/
@js.native
@JSGlobal
class ImageCapture(
init: MediaStreamTrack
) extends js.Object {

/**
* Returns a reference to the MediaStreamTrack passed to the constructor.
*
* MDN
*/
val track: MediaStreamTrack = js.native

/**
* Takes a single exposure using the video capture device sourcing a MediaStreamTrack and
* returns a Promise that resolves with a Blob containing the data.
*
* MDN
*/
def takePhoto(): js.Promise[Blob] = js.native

/**
* Takes a snapshot of the live video in a MediaStreamTrack, returning an ImageBitmap, if
* successful.
*
* MDN
*/
def grabFrame(): js.Promise[ImageBitmap] = js.native

}
35 changes: 35 additions & 0 deletions src/main/scala/org/scalajs/dom/raw/lib.scala
Original file line number Diff line number Diff line change
Expand Up @@ -6045,6 +6045,41 @@ class ImageData extends js.Object {
def height: Int = js.native
}

/**
* The ImageBitmap interface represents a bitmap image which can be drawn to a <canvas>
* without undue latency. It can be created from a variety of source objects using the
* createImageBitmap() factory method. ImageBitmap provides an asynchronous and resource
* efficient pathway to prepare textures for rendering in WebGL.
*
* MDN
*/
@js.native
@JSGlobal
class ImageBitmap extends js.Object {

/**
* Is an unsigned long representing the height, in CSS pixels, of the ImageBitmap.
*
* MDN
*/
def height: Int = js.native

/**
* Is an unsigned long representing the width, in CSS pixels, of the ImageBitmap.
*
* MDN
*/
def width: Int = js.native

/**
* Dispose of all graphical resources associated with an ImageBitmap.
*
* MDN
*/
def close(): Unit = js.native

}

/**
* A collection of nodes returned by Node.attributes (also potentially for
* DocumentType.entities, DocumentType.notations). NamedNodeMaps are not in any
Expand Down