MediaSession.webidl (2050B)
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/. 5 * 6 * The origin of this IDL file is 7 * https://w3c.github.io/mediasession/#idl-index 8 */ 9 10 enum MediaSessionPlaybackState { 11 "none", 12 "paused", 13 "playing" 14 }; 15 16 enum MediaSessionAction { 17 "play", 18 "pause", 19 "seekbackward", 20 "seekforward", 21 "previoustrack", 22 "nexttrack", 23 "skipad", 24 "seekto", 25 "stop", 26 }; 27 28 callback MediaSessionActionHandler = undefined(MediaSessionActionDetails details); 29 30 [Exposed=Window] 31 interface MediaSession { 32 attribute MediaMetadata? metadata; 33 34 attribute MediaSessionPlaybackState playbackState; 35 36 undefined setActionHandler(MediaSessionAction action, MediaSessionActionHandler? handler); 37 38 [Throws] 39 undefined setPositionState(optional MediaPositionState state = {}); 40 41 // Fire the action handler. It's test-only for now. 42 [ChromeOnly] 43 undefined notifyHandler(MediaSessionActionDetails details); 44 }; 45 46 [Exposed=Window] 47 interface MediaMetadata { 48 [Throws] 49 constructor(optional MediaMetadataInit init = {}); 50 51 attribute DOMString title; 52 attribute DOMString artist; 53 attribute DOMString album; 54 // https://github.com/w3c/mediasession/issues/237 55 // Take and return `MediaImage` on setter and getter. 56 [Frozen, Cached, Pure, Throws] 57 attribute sequence<object> artwork; 58 }; 59 60 dictionary MediaMetadataInit { 61 DOMString title = ""; 62 DOMString artist = ""; 63 DOMString album = ""; 64 sequence<MediaImage> artwork = []; 65 }; 66 67 dictionary MediaImage { 68 required USVString src; 69 DOMString sizes = ""; 70 DOMString type = ""; 71 }; 72 73 // Spec issue https://github.com/w3c/mediasession/issues/254 74 dictionary MediaSessionActionDetails { 75 required MediaSessionAction action; 76 double seekOffset; 77 double seekTime; 78 boolean fastSeek; 79 }; 80 81 dictionary MediaPositionState { 82 double duration; 83 double playbackRate; 84 double position; 85 };