Raw File
interfaces.html
<!doctype html>
<meta charset=utf-8>
<title>Media Source Extensions IDL tests</title>
<div id=log></div>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<script src=/resources/WebIDLParser.js></script>
<script src=/resources/idlharness.js></script>
<script type=text/plain class=untested>
interface EventTarget {
  void addEventListener(DOMString type, EventListener? callback, optional boolean capture /* = false */);
  void removeEventListener(DOMString type, EventListener? callback, optional boolean capture /* = false */);
  boolean dispatchEvent(Event event);
};
interface URL {};
interface HTMLVideoElement {};
interface AudioTrack {};
interface AudioTrackList {};
interface VideoTrack {};
interface VideoTrackList {};
interface TextTrack {};
interface TextTrackList {};
interface TimeRanges {};
typedef double DOMHighResTimeStamp;
</script>
<script type=text/plain>
[Constructor]
interface MediaSource : EventTarget {
    readonly    attribute SourceBufferList    sourceBuffers;
    readonly    attribute SourceBufferList    activeSourceBuffers;
    readonly    attribute ReadyState          readyState;
                attribute unrestricted double duration;
                attribute EventHandler        onsourceopen;
                attribute EventHandler        onsourceended;
                attribute EventHandler        onsourceclose;
    SourceBuffer   addSourceBuffer (DOMString type);
    void           removeSourceBuffer (SourceBuffer sourceBuffer);
    void           endOfStream (optional EndOfStreamError error);
    void           setLiveSeekableRange (double start, double end);
    void           clearLiveSeekableRange ();
    static boolean isTypeSupported (DOMString type);
};

interface SourceBuffer : EventTarget {
                attribute AppendMode          mode;
    readonly    attribute boolean             updating;
    readonly    attribute TimeRanges          buffered;
                attribute double              timestampOffset;
    readonly    attribute AudioTrackList      audioTracks;
    readonly    attribute VideoTrackList      videoTracks;
    readonly    attribute TextTrackList       textTracks;
                attribute double              appendWindowStart;
                attribute unrestricted double appendWindowEnd;
                attribute EventHandler        onupdatestart;
                attribute EventHandler        onupdate;
                attribute EventHandler        onupdateend;
                attribute EventHandler        onerror;
                attribute EventHandler        onabort;
    void appendBuffer (ArrayBuffer data);
    void appendBuffer (ArrayBufferView data);
    void appendStream (ReadableStream stream, [EnforceRange] optional unsigned long long maxSize);
    void abort ();
    void remove (double start, unrestricted double end);
                    attribute TrackDefaultList    trackDefaults;
};

interface SourceBufferList : EventTarget {
    readonly    attribute unsigned long length;
                attribute EventHandler  onaddsourcebuffer;
                attribute EventHandler  onremovesourcebuffer;
    getter SourceBuffer (unsigned long index);
};

interface VideoPlaybackQuality {
    readonly    attribute DOMHighResTimeStamp creationTime;
    readonly    attribute unsigned long       totalVideoFrames;
    readonly    attribute unsigned long       droppedVideoFrames;
    readonly    attribute unsigned long       corruptedVideoFrames;
    readonly    attribute double              totalFrameDelay;
};

[ Constructor (TrackDefaultType type, DOMString language, DOMString label, sequence<DOMString> kinds, optional DOMString byteStreamTrackID = "")]
interface TrackDefault {
    readonly    attribute TrackDefaultType    type;
    readonly    attribute DOMString           byteStreamTrackID;
    readonly    attribute DOMString           language;
    readonly    attribute DOMString           label;
    sequence<DOMString> getKinds ();
};

[ Constructor (optional sequence<TrackDefault> trackDefaults = [])]
interface TrackDefaultList {
    readonly    attribute unsigned long length;
    getter TrackDefault (unsigned long index);
};

[Exposed=Window,DedicatedWorker,SharedWorker]
partial interface URL {
    static DOMString createObjectURL (MediaSource mediaSource);
};

partial interface HTMLVideoElement {
    VideoPlaybackQuality getVideoPlaybackQuality ();
};

partial interface AudioTrack {
    readonly    attribute SourceBuffer? sourceBuffer;
};

partial interface VideoTrack {
    readonly    attribute SourceBuffer? sourceBuffer;
};

partial interface TextTrack {
    readonly    attribute SourceBuffer? sourceBuffer;
};

enum EndOfStreamError {
    "network",
    "decode"
};

enum AppendMode {
    "segments",
    "sequence"
};

enum ReadyState {
    "closed",
    "open",
    "ended"
};

enum TrackDefaultType {
    "audio",
    "video",
    "text"
};
</script>
<script>
"use strict";
var mediaSource;
var sourceBuffer;
var video = document.createElement("video");
var idlCheck = function() {
  var idlArray = new IdlArray();
  [].forEach.call(document.querySelectorAll("script[type=text\\/plain]"), function(node) {
    if (node.className == "untested") {
      idlArray.add_untested_idls(node.textContent);
    } else {
      idlArray.add_idls(node.textContent);
    }
  });
  idlArray.add_objects({
    MediaSource: ['mediaSource'],
    SourceBuffer: ['sourceBuffer'],
    SourceBufferList: ['mediaSource.sourceBuffers'],
    VideoPlaybackQuality: ['video.getVideoPlaybackQuality()'],
    TrackDefaultList: ['sourceBuffer.trackDefaults']
  });
  idlArray.test();
}
mediaSource = new MediaSource();
video.src = URL.createObjectURL(mediaSource);
mediaSource.addEventListener("sourceopen", function () {
  var defaultType ='video/webm;codecs="vp8,vorbis"';
  if (video.canPlayType(defaultType)) {
    sourceBuffer = mediaSource.addSourceBuffer(defaultType);
  } else {
    sourceBuffer = mediaSource.addSourceBuffer('video/mp4');
  }
  sourceBuffer.addEventListener("updateend", function (e) {
    mediaSource.endOfStream();
    idlCheck();
  });
  sourceBuffer.appendBuffer(new ArrayBuffer());
});
</script>
back to top