Backed out changeset 2450366cf7ca (bug 1891629) for causing win msix mochitest failures
[gecko.git] / dom / chrome-webidl / MediaController.webidl
blobb16282877ae89d8fb73625b8b4f670b69f77a4dc
1 /* This Source Code Form is subject to the terms of the Mozilla Public
2  * License, v. 2.0. If a copy of the MPL was not distributed with this file,
3  * You can obtain one at http://mozilla.org/MPL/2.0/.
4  */
6 /**
7  * This enum lists all supported behaviors on the media controller.
8  */
9 enum MediaControlKey {
10   "focus",
11   "play",
12   "pause",
13   "playpause",
14   "previoustrack",
15   "nexttrack",
16   "seekbackward",
17   "seekforward",
18   "skipad",
19   "seekto",
20   "stop",
23 /**
24  * MediaController is used to control media playback for a tab, and each tab
25  * would only have one media controller, which can be accessed from the
26  * canonical browsing context.
27  */
28 [Exposed=Window, ChromeOnly]
29 interface MediaController : EventTarget {
30   readonly attribute unsigned long long id;
31   readonly attribute boolean isActive;
32   readonly attribute boolean isAudible;
33   readonly attribute boolean isPlaying;
34   readonly attribute MediaSessionPlaybackState playbackState;
36   [Throws]
37   MediaMetadataInit getMetadata();
39   [Frozen, Cached, Pure]
40   readonly attribute sequence<MediaControlKey> supportedKeys;
42   attribute EventHandler onactivated;
43   attribute EventHandler ondeactivated;
45   // Following events would only be dispatched after controller is active.
46   attribute EventHandler onmetadatachange;
47   attribute EventHandler onplaybackstatechange;
48   attribute EventHandler onpositionstatechange;
49   attribute EventHandler onsupportedkeyschange;
51   undefined focus();
52   undefined play();
53   undefined pause();
54   undefined stop();
55   undefined prevTrack();
56   undefined nextTrack();
57   undefined seekBackward();
58   undefined seekForward();
59   undefined skipAd();
60   undefined seekTo(double seekTime, optional boolean fastSeek = false);
63 [ChromeOnly,Exposed=Window,HeaderFile="mozilla/dom/MediaControlService.h"]
64 namespace MediaControlService {
65   // This is used to generate fake media control keys event in testing.
66   undefined generateMediaControlKey(MediaControlKey aKey);
68   // This is used to get the media metadata from the current main controller in
69   // testing.
70   MediaMetadataInit getCurrentActiveMediaMetadata();
72   // This is used to get the actual media playback state from the current main
73   // controller in testing.
74   MediaSessionPlaybackState getCurrentMediaSessionPlaybackState();