MediaController.webidl (2339B)
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 */ 5 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", 21 }; 22 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; 35 36 [Throws] 37 MediaMetadataInit getMetadata(); 38 39 [Frozen, Cached, Pure] 40 readonly attribute sequence<MediaControlKey> supportedKeys; 41 42 attribute EventHandler onactivated; 43 attribute EventHandler ondeactivated; 44 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; 50 51 undefined focus(); 52 undefined play(); 53 undefined pause(); 54 undefined stop(); 55 undefined prevTrack(); 56 undefined nextTrack(); 57 undefined seekBackward(double seekOffset); 58 undefined seekForward(double seekOffset); 59 undefined skipAd(); 60 undefined seekTo(double seekTime, optional boolean fastSeek = false); 61 }; 62 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); 67 68 // This is used to get the media metadata from the current main controller in 69 // testing. 70 MediaMetadataInit getCurrentActiveMediaMetadata(); 71 72 // This is used to get the actual media playback state from the current main 73 // controller in testing. 74 MediaSessionPlaybackState getCurrentMediaSessionPlaybackState(); 75 };