1 /* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
4 * You can obtain one at http://mozilla.org/MPL/2.0/.
6 * The origin of this IDL file is
7 * http://www.whatwg.org/specs/web-apps/current-work/#media-elements
9 * © Copyright 2004-2011 Apple Computer, Inc., Mozilla Foundation, and
10 * Opera Software ASA. You are granted a license to use, reproduce
11 * and create derivative works of this document.
15 interface HTMLMediaElement : HTMLElement {
18 readonly attribute MediaError? error;
21 [CEReactions, SetterNeedsSubjectPrincipal=NonSystem, SetterThrows]
22 attribute DOMString src;
23 readonly attribute DOMString currentSrc;
25 [CEReactions, SetterThrows]
26 attribute DOMString? crossOrigin;
27 const unsigned short NETWORK_EMPTY = 0;
28 const unsigned short NETWORK_IDLE = 1;
29 const unsigned short NETWORK_LOADING = 2;
30 const unsigned short NETWORK_NO_SOURCE = 3;
31 readonly attribute unsigned short networkState;
32 [CEReactions, SetterThrows]
33 attribute DOMString preload;
35 readonly attribute TimeRanges buffered;
37 DOMString canPlayType(DOMString type);
40 const unsigned short HAVE_NOTHING = 0;
41 const unsigned short HAVE_METADATA = 1;
42 const unsigned short HAVE_CURRENT_DATA = 2;
43 const unsigned short HAVE_FUTURE_DATA = 3;
44 const unsigned short HAVE_ENOUGH_DATA = 4;
45 readonly attribute unsigned short readyState;
46 readonly attribute boolean seeking;
50 attribute double currentTime;
52 void fastSeek(double time);
53 readonly attribute unrestricted double duration;
55 readonly attribute boolean isEncrypted;
56 // TODO: Bug 847376 - readonly attribute any startDate;
57 readonly attribute boolean paused;
59 attribute double defaultPlaybackRate;
61 attribute double playbackRate;
63 readonly attribute TimeRanges played;
65 readonly attribute TimeRanges seekable;
66 readonly attribute boolean ended;
67 [CEReactions, SetterThrows]
68 attribute boolean autoplay;
69 [CEReactions, SetterThrows]
70 attribute boolean loop;
76 // TODO: Bug 847377 - mediaGroup and MediaController
78 // attribute DOMString mediaGroup;
79 // attribute MediaController? controller;
82 [CEReactions, SetterThrows]
83 attribute boolean controls;
85 attribute double volume;
86 attribute boolean muted;
87 [CEReactions, SetterThrows]
88 attribute boolean defaultMuted;
92 [Pref="media.track.enabled"]
93 readonly attribute AudioTrackList audioTracks;
94 [Pref="media.track.enabled"]
95 readonly attribute VideoTrackList videoTracks;
96 readonly attribute TextTrackList? textTracks;
97 TextTrack addTextTrack(TextTrackKind kind,
98 optional DOMString label = "",
99 optional DOMString language = "");
102 // Mozilla extensions:
103 partial interface HTMLMediaElement {
104 [Func="HasDebuggerOrTabsPrivilege"]
105 readonly attribute MediaSource? mozMediaSourceObject;
107 [Func="HasDebuggerOrTabsPrivilege", NewObject]
108 Promise<HTMLMediaElementDebugInfo> mozRequestDebugInfo();
110 [Func="HasDebuggerOrTabsPrivilege", NewObject]
111 static void mozEnableDebugLog();
112 [Func="HasDebuggerOrTabsPrivilege", NewObject]
113 Promise<DOMString> mozRequestDebugLog();
115 attribute MediaStream? srcObject;
117 // TODO: Remove mozPreservesPitch. (bug 1765201)
118 [Deprecated="MozPreservesPitchDeprecatedPrefix", BinaryName="preservesPitch"]
119 attribute boolean mozPreservesPitch;
120 attribute boolean preservesPitch;
122 // NB: for internal use with the video controls:
123 [Func="IsChromeOrUAWidget"] attribute boolean mozAllowCasting;
124 [Func="IsChromeOrUAWidget"] attribute boolean mozIsCasting;
126 // Mozilla extension: stream capture
128 MediaStream mozCaptureStream();
130 MediaStream mozCaptureStreamUntilEnded();
131 readonly attribute boolean mozAudioCaptured;
133 // Mozilla extension: return embedded metadata from the stream as a
134 // JSObject with key:value pairs for each tag. This can be used by
135 // player interfaces to display the song title, artist, etc.
137 object? mozGetMetadata();
139 // Mozilla extension: provides access to the fragment end time if
140 // the media element has a fragment URI for the currentSrc, otherwise
141 // it is equal to the media duration.
142 readonly attribute double mozFragmentEnd;
145 // Encrypted Media Extensions
146 partial interface HTMLMediaElement {
147 readonly attribute MediaKeys? mediaKeys;
149 // void, not any: https://www.w3.org/Bugs/Public/show_bug.cgi?id=26457
151 Promise<void> setMediaKeys(MediaKeys? mediaKeys);
153 attribute EventHandler onencrypted;
155 attribute EventHandler onwaitingforkey;
159 * These attributes are general testing attributes and they should only be used
162 partial interface HTMLMediaElement {
163 [Pref="media.useAudioChannelService.testing"]
164 readonly attribute double computedVolume;
166 [Pref="media.useAudioChannelService.testing"]
167 readonly attribute boolean computedMuted;
169 // Return true if the media is suspended because its document is inactive or
170 // the docshell is inactive and explicitly being set to prohibit all media
173 readonly attribute boolean isSuspendedByInactiveDocOrDocShell;
177 * HTMLMediaElement::seekToNextFrame() is a Mozilla experimental feature.
179 * The SeekToNextFrame() method provides a way to access a video element's video
180 * frames one by one without going through the realtime playback. So, it lets
181 * authors use "frame" as unit to access the video element's underlying data,
184 * The SeekToNextFrame() is a kind of seek operation, so normally, once it is
185 * invoked, a "seeking" event is dispatched. However, if the media source has no
186 * video data or is not seekable, the operation is ignored without filing the
189 * Once the SeekToNextFrame() is done, a "seeked" event should always be filed
190 * and a "ended" event might also be filed depends on where the media element's
191 * position before seeking was. There are two cases:
192 * Assume the media source has n+1 video frames where n is a non-negative
193 * integers and the frame sequence is indexed from zero.
194 * (1) If the currentTime is at anywhere smaller than the n-th frame's beginning
195 * time, say the currentTime is now pointing to a position which is smaller
196 * than the x-th frame's beginning time and larger or equal to the (x-1)-th
197 * frame's beginning time, where x belongs to [1, n], then the
198 * SeekToNextFrame() operation seeks the media to the x-th frame, sets the
199 * media's currentTime to the x-th frame's beginning time and dispatches a
201 * (2) Otherwise, if the currentTime is larger or equal to the n-th frame's
202 * beginning time, then the SeekToNextFrame() operation sets the media's
203 * currentTime to the duration of the media source and dispatches a "seeked"
204 * event and an "ended" event.
206 partial interface HTMLMediaElement {
207 [NewObject, Pref="media.seekToNextFrame.enabled"]
208 Promise<void> seekToNextFrame();
211 /* Internal testing only API */
212 partial interface HTMLMediaElement {
213 // These APIs are used to simulate visibility changes to help debug and write
214 // tests about suspend-video-decoding.
215 // - SetVisible() is for simulating visibility changes.
216 // - HasSuspendTaint() is for querying that the element's decoder cannot suspend
217 // video decoding because it has been tainted by an operation, such as
219 // - isInViewPort is a boolean value which indicate whether media element is
221 // - isVideoDecodingSuspended() is used to know whether video decoding has
223 [Pref="media.test.video-suspend"]
224 void setVisible(boolean aVisible);
226 [Pref="media.test.video-suspend"]
227 boolean hasSuspendTaint();
230 readonly attribute boolean isInViewPort;
233 readonly attribute boolean isVideoDecodingSuspended;
236 readonly attribute double totalVideoPlayTime;
239 readonly attribute double totalVideoHDRPlayTime;
242 readonly attribute double visiblePlayTime;
245 readonly attribute double invisiblePlayTime;
248 readonly attribute double videoDecodeSuspendedTime;
251 readonly attribute double totalAudioPlayTime;
254 readonly attribute double audiblePlayTime;
257 readonly attribute double inaudiblePlayTime;
260 readonly attribute double mutedPlayTime;
262 // These APIs are used for decoder doctor tests.
264 void setFormatDiagnosticsReportForMimeType(DOMString mimeType, DecoderDoctorReportType error);
267 void setDecodeError(DOMString error);
270 void setAudioSinkFailedStartup();
273 /* Audio Output Devices API
274 * https://w3c.github.io/mediacapture-output/
276 partial interface HTMLMediaElement {
277 [SecureContext, Pref="media.setsinkid.enabled"]
278 readonly attribute DOMString sinkId;
279 [NewObject, SecureContext, Pref="media.setsinkid.enabled"]
280 Promise<void> setSinkId(DOMString sinkId);
284 * API that exposes whether a call to HTMLMediaElement.play() would be
285 * blocked by autoplay policies; whether the promise returned by play()
286 * would be rejected with NotAllowedError.
288 partial interface HTMLMediaElement {
289 [Pref="media.allowed-to-play.enabled"]
290 readonly attribute boolean allowedToPlay;