Skip to content
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

Added ImageCapture #410

Merged
merged 7 commits into from
Sep 4, 2021
Merged
Show file tree
Hide file tree
Changes from all 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
4 changes: 4 additions & 0 deletions api-reports/2_12.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13250,6 +13250,7 @@ IDBVersionChangeEventInit[JT] var composed: js.UndefOr[Boolean]
IDBVersionChangeEventInit[JT] var newVersion: js.UndefOr[Integer]
IDBVersionChangeEventInit[JT] var oldVersion: js.UndefOr[Int]
IDBVersionChangeEventInit[JT] var scoped: js.UndefOr[Boolean]
ImageBitmap[JT] def close(): Unit
ImageBitmap[JT] def height: Double
ImageBitmap[JT] def width: Double
ImageData[JC] def data: js.Array[Int]
Expand Down Expand Up @@ -23627,6 +23628,9 @@ experimental/mediastream/AudioTrackList[JT] var onchange: js.Function1[Event, An
experimental/mediastream/AudioTrackList[JT] var onremovetrack: js.Function1[Event, Any]
experimental/mediastream/AudioTrackList[JT] def removeEventListener[T <: Event](`type`: String, listener: js.Function1[T, _], options: EventListenerOptions): Unit
experimental/mediastream/AudioTrackList[JT] def removeEventListener[T <: Event](`type`: String, listener: js.Function1[T, _], useCapture: Boolean?): Unit
experimental/mediastream/ImageCapture[JC] def grabFrame(): js.Promise[ImageBitmap]
experimental/mediastream/ImageCapture[JC] def takePhoto(): js.Promise[Blob]
experimental/mediastream/ImageCapture[JC] val track: MediaStreamTrack
japgolly marked this conversation as resolved.
Show resolved Hide resolved
experimental/mediastream/MediaDeviceInfo[JT] val deviceId: String
experimental/mediastream/MediaDeviceInfo[JT] val groupId: String
experimental/mediastream/MediaDeviceInfo[JT] val kind: MediaDeviceKind
Expand Down
4 changes: 4 additions & 0 deletions api-reports/2_13.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13250,6 +13250,7 @@ IDBVersionChangeEventInit[JT] var composed: js.UndefOr[Boolean]
IDBVersionChangeEventInit[JT] var newVersion: js.UndefOr[Integer]
IDBVersionChangeEventInit[JT] var oldVersion: js.UndefOr[Int]
IDBVersionChangeEventInit[JT] var scoped: js.UndefOr[Boolean]
ImageBitmap[JT] def close(): Unit
ImageBitmap[JT] def height: Double
ImageBitmap[JT] def width: Double
ImageData[JC] def data: js.Array[Int]
Expand Down Expand Up @@ -23627,6 +23628,9 @@ experimental/mediastream/AudioTrackList[JT] var onchange: js.Function1[Event, An
experimental/mediastream/AudioTrackList[JT] var onremovetrack: js.Function1[Event, Any]
experimental/mediastream/AudioTrackList[JT] def removeEventListener[T <: Event](`type`: String, listener: js.Function1[T, _], options: EventListenerOptions): Unit
experimental/mediastream/AudioTrackList[JT] def removeEventListener[T <: Event](`type`: String, listener: js.Function1[T, _], useCapture: Boolean?): Unit
experimental/mediastream/ImageCapture[JC] def grabFrame(): js.Promise[ImageBitmap]
experimental/mediastream/ImageCapture[JC] def takePhoto(): js.Promise[Blob]
experimental/mediastream/ImageCapture[JC] val track: MediaStreamTrack
experimental/mediastream/MediaDeviceInfo[JT] val deviceId: String
experimental/mediastream/MediaDeviceInfo[JT] val groupId: String
experimental/mediastream/MediaDeviceInfo[JT] val kind: MediaDeviceKind
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,12 @@ trait ImageBitmap extends js.Object {
/** An unsigned long representing the width, in CSS pixels, of the ImageData.
*/
def width: Double = js.native

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

trait CreateImageBitmapOptions extends js.Object {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
*/
package org.scalajs.dom.experimental.mediastream

import org.scalajs.dom.{Event, EventInit, EventTarget, TimeRanges}
import org.scalajs.dom._
import scala.scalajs.js
import scala.scalajs.js.annotation._
import scala.scalajs.js.|
Expand Down Expand Up @@ -525,6 +525,37 @@ trait MediaTrackSupportedConstraints extends js.Object {
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
}

/** Represents a source of media data for an HTMLMediaElement object.
*
* A MediaSource object can be attached to a HTMLMediaElement to be played in the user agent.
Expand Down