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/.
7 * This enum lists all supported behaviors on the media controller.
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.
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;
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;
55 undefined prevTrack();
56 undefined nextTrack();
57 undefined seekBackward(double seekOffset);
58 undefined seekForward(double seekOffset);
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, optional double aSeekValue = 0.0);
68 // This is used to get the media metadata from the current main controller in
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();