Skip to content

Commit

Permalink
Follow the standardized IDL type.
Browse files Browse the repository at this point in the history
  • Loading branch information
exoego committed Feb 5, 2020
1 parent e99ba6c commit 0a15f36
Show file tree
Hide file tree
Showing 3 changed files with 194 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ package org.scalajs.dom.experimental.mediastream
import scala.scalajs.js
import scala.scalajs.js.|
import scala.scalajs.js.annotation._
import org.scalajs.dom.raw.{DOMException, Event, EventInit, EventTarget}
import org.scalajs.dom.raw.{
DOMError, DOMException, Event, EventInit, EventTarget, TimeRanges
}

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

/**
* 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.
*/
@js.native
@JSGlobal
class MediaSource extends EventTarget {
def sourceBueffers: SourceBufferList = js.native
def activeSourceBuffers: SourceBufferList = js.native
def readyState: ReadyState = js.native

/**
* Allows the web application to set the presentation duration.
*
* The duration is initially set to NaN when the MediaSource object is created.
*/
var duration: Double = js.native

var onsourceopen: js.Function1[Event, Any] = js.native
var onsourceended: js.Function1[Event, Any] = js.native
var onsourceclose: js.Function1[Event, Any] = js.native

def addSourceBuffer(bufferType: String): SourceBuffer = js.native
def removeSourceBuffer(sourceBuffer: SourceBuffer): Unit = js.native
def endOfStream(error: js.UndefOr[EndOfStreamError] = ???): Unit = js.native
def setLiveSeekableRange(start: Double, end: Double): Unit = js.native
def clearLiveSeekableRange(): Unit = js.native
}

@js.native
@JSGlobalScope
object MediaSource extends js.Object {
def isTypeSupported(mediaType: String): Boolean = js.native
}

@js.native
trait SourceBufferList extends EventTarget {
def length: Double = js.native

@JSBracketAccess
def apply(index: Double): SourceBuffer = js.native

var onaddsourcebuffer: js.Function1[Event, Any] = js.native
var onremovesourcebuffer: js.Function1[Event, Any] = js.native
}

@js.native
trait SourceBuffer extends EventTarget {
var mode: AppendMode = js.native
var timestampOffset: Double = js.native

def updating: Boolean = js.native
def buffered: TimeRanges = js.native

def audioTracks: AudioTrackList = js.native
def videoTracks: VideoTrackList = js.native
def textTracks: TextTrackList = js.native

var appendWindowStart: Double = js.native
var appendWindowEnd: Double = js.native

var onupdatestart: js.Function1[Event, Any] = js.native
var onupdate: js.Function1[Event, Any] = js.native
var onupdateend: js.Function1[Event, Any] = js.native
var onerror: js.Function1[Event, Any] = js.native
var onabort: js.Function1[Event, Any] = js.native

def appendBuffer(data: BufferSource): Unit = js.native
def abort(): Unit = js.native
def remove(start: Double, end: Double): Unit = js.native
}

@js.native
trait AudioTrackList extends EventTarget {
def length: Double = js.native

@JSBracketAccess
def apply(index: Double): AudioTrack = js.native

def getTrackById(id: String): js.UndefOr[AudioTrack] = js.native

var onchange: js.Function1[Event, Any] = js.native
var onaddtrack: js.Function1[Event, Any] = js.native
var onremovetrack: js.Function1[Event, Any] = js.native
}

@js.native
trait AudioTrack extends js.Object {
val id: String = js.native
val kind: String = js.native
val label: String = js.native
val language: String = js.native
var enabled: Boolean = js.native
}

@js.native
trait VideoTrackList extends EventTarget {
def length: Double = js.native

@JSBracketAccess
def apply(index: Double): VideoTrack = js.native

def getTrackById(id: String): js.UndefOr[VideoTrack] = js.native

def selectedIndex: Double = js.native

var onchange: js.Function1[Event, Any] = js.native
var onaddtrack: js.Function1[Event, Any] = js.native
var onremovetrack: js.Function1[Event, Any] = js.native
}
@js.native
trait VideoTrack extends js.Object {
val id: String = js.native
val kind: String = js.native
val label: String = js.native
val language: String = js.native
var selected: Boolean = js.native
}
@js.native
trait TextTrackList extends EventTarget {

def length: Double = js.native

@JSBracketAccess
def apply(index: Double): VideoTrack = js.native

def getTrackById(id: String): js.UndefOr[TextTrack] = js.native;

var onchange: js.Function1[Event, Any] = js.native
var onaddtrack: js.Function1[Event, Any] = js.native
var onremovetrack: js.Function1[Event, Any] = js.native
}
@js.native
trait TextTrack extends EventTarget {
val id: String = js.native
val kind: String = js.native
val label: String = js.native
val language: String = js.native
val inBandMetadataTrackDispatchType: String = js.native

var mode: TextTrackMode = js.native

def cues: js.UndefOr[TextTrackCueList] = js.native
def activeCues: js.UndefOr[TextTrackCueList] = js.native

def addCue(cue: TextTrackCue): Unit = js.native
def removeCue(cue: TextTrackCue): Unit = js.native

var oncuechange: js.Function1[Event, Any] = js.native
}

@js.native
trait TextTrackCueList extends js.Object {
def length: Double = js.native

@JSBracketAccess
def apply(index: Double): TextTrackCue = js.native

def getCueById(id: String): js.UndefOr[TextTrackCue] = js.native;
}

@js.native
trait TextTrackCue extends EventTarget {
def track: js.UndefOr[TextTrack] = js.native

var id: String = js.native
var startTime: Double = js.native
var endTime: Double = js.native
var pauseOnExit: Boolean = js.native

var onenter: js.Function1[Event, Any] = js.native
var onexit: js.Function1[Event, Any] = js.native
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package org.scalajs.dom.experimental

import scala.scalajs.js
import scala.scalajs.js.|

package object mediastream {
type BufferSource = js.typedarray.ArrayBufferView | js.typedarray.ArrayBuffer
type AppendMode = String
type TextTrackMode = String
type EndOfStreamError = String
type ReadyState = String
}
5 changes: 4 additions & 1 deletion src/main/scala/org/scalajs/dom/raw/Html.scala
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ package org.scalajs.dom.raw

import scala.scalajs.js
import scala.scalajs.js.annotation._
import scala.scalajs.js.|
import org.scalajs.dom

@js.native
@JSGlobal
Expand Down Expand Up @@ -3804,7 +3806,8 @@ abstract class HTMLMediaElement extends HTMLElement {
/**
* Sets or returns the object which serves as the source of the media associated with the HTMLMediaElement.
*/
var srcObject: org.scalajs.dom.experimental.mediastream.MediaStream
var srcObject: js.UndefOr[
dom.experimental.mediastream.MediaStream | dom.experimental.mediastream.MediaSource | Blob]
}

@js.native
Expand Down

0 comments on commit 0a15f36

Please sign in to comment.