@jellybrick/mpris-service 2.1.3 → 2.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/constants.js.map +1 -1
- package/dist/index.js +30 -40
- package/dist/index.js.map +1 -1
- package/dist/interfaces/mpris-interface.js +6 -14
- package/dist/interfaces/mpris-interface.js.map +1 -1
- package/dist/interfaces/player.js +38 -41
- package/dist/interfaces/player.js.map +1 -1
- package/dist/interfaces/playlists.js +23 -27
- package/dist/interfaces/playlists.js.map +1 -1
- package/dist/interfaces/root.js +29 -34
- package/dist/interfaces/root.js.map +1 -1
- package/dist/interfaces/tracklist.js +22 -26
- package/dist/interfaces/tracklist.js.map +1 -1
- package/dist/interfaces/types.js +2 -2
- package/dist/interfaces/types.js.map +1 -1
- package/dist/logging.js +1 -1
- package/dist/logging.js.map +1 -1
- package/package.json +11 -11
- package/src/index.js +7 -7
- package/src/interfaces/mpris-interface.js +5 -9
- package/src/interfaces/player.js +8 -5
- package/src/interfaces/playlists.js +10 -8
- package/src/interfaces/root.js +7 -6
- package/src/interfaces/tracklist.js +8 -7
- package/src/interfaces/types.js +2 -2
- package/src/logging.js +1 -1
- package/.idea/discord.xml +0 -7
- package/.idea/jsLibraryMappings.xml +0 -6
- package/.idea/modules.xml +0 -8
- package/.idea/mpris-service.iml +0 -12
- package/.idea/vcs.xml +0 -6
package/dist/constants.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","names":["constants","PLAYBACK_STATUS_PLAYING","PLAYBACK_STATUS_PAUSED","PLAYBACK_STATUS_STOPPED","LOOP_STATUS_NONE","LOOP_STATUS_TRACK","LOOP_STATUS_PLAYLIST","playbackStatuses","loopStatuses","isLoopStatusValid","value","includes","isPlaybackStatusValid","module","exports"],"sourceRoot":"../src/","sources":["constants.js"],"sourcesContent":["const constants = {\n PLAYBACK_STATUS_PLAYING: 'Playing',\n PLAYBACK_STATUS_PAUSED: 'Paused',\n PLAYBACK_STATUS_STOPPED: 'Stopped',\n\n LOOP_STATUS_NONE: 'None',\n LOOP_STATUS_TRACK: 'Track',\n LOOP_STATUS_PLAYLIST: 'Playlist'\n};\n\nconst playbackStatuses = [\n constants.PLAYBACK_STATUS_PLAYING,\n constants.PLAYBACK_STATUS_PAUSED,\n constants.PLAYBACK_STATUS_STOPPED\n];\n\nconst loopStatuses = [\n constants.LOOP_STATUS_NONE,\n constants.LOOP_STATUS_PLAYLIST,\n constants.LOOP_STATUS_TRACK\n];\n\nconstants.isLoopStatusValid = function(value) {\n return loopStatuses.includes(value);\n};\n\nconstants.isPlaybackStatusValid = function(value) {\n return playbackStatuses.includes(value);\n};\n\nmodule.exports = constants;\n"],"mappings":";;AAAA,MAAMA,SAAS,GAAG;EAChBC,uBAAuB,EAAE,SAAS;EAClCC,sBAAsB,EAAE,QAAQ;EAChCC,uBAAuB,EAAE,SAAS;EAElCC,gBAAgB,EAAE,MAAM;EACxBC,iBAAiB,EAAE,OAAO;EAC1BC,oBAAoB,EAAE;AACxB,CAAC;AAED,MAAMC,gBAAgB,GAAG,CACvBP,SAAS,CAACC,uBAAuB,EACjCD,SAAS,CAACE,sBAAsB,EAChCF,SAAS,CAACG,uBAAuB,CAClC;AAED,MAAMK,YAAY,GAAG,CACnBR,SAAS,CAACI,gBAAgB,EAC1BJ,SAAS,CAACM,oBAAoB,EAC9BN,SAAS,CAACK,iBAAiB,CAC5B;AAEDL,SAAS,CAACS,iBAAiB,GAAG,UAASC,KAAK,EAAE;EAC5C,OAAOF,YAAY,CAACG,QAAQ,CAACD,KAAK,CAAC;AACrC,CAAC;AAEDV,SAAS,CAACY,qBAAqB,GAAG,UAASF,KAAK,EAAE;EAChD,OAAOH,gBAAgB,CAACI,QAAQ,CAACD,KAAK,CAAC;AACzC,CAAC;AAEDG,MAAM,CAACC,OAAO,GAAGd,SAAS"}
|
|
1
|
+
{"version":3,"file":"constants.js","names":["constants","PLAYBACK_STATUS_PLAYING","PLAYBACK_STATUS_PAUSED","PLAYBACK_STATUS_STOPPED","LOOP_STATUS_NONE","LOOP_STATUS_TRACK","LOOP_STATUS_PLAYLIST","playbackStatuses","loopStatuses","isLoopStatusValid","value","includes","isPlaybackStatusValid","module","exports"],"sourceRoot":"../src/","sources":["constants.js"],"sourcesContent":["const constants = {\n PLAYBACK_STATUS_PLAYING: 'Playing',\n PLAYBACK_STATUS_PAUSED: 'Paused',\n PLAYBACK_STATUS_STOPPED: 'Stopped',\n\n LOOP_STATUS_NONE: 'None',\n LOOP_STATUS_TRACK: 'Track',\n LOOP_STATUS_PLAYLIST: 'Playlist'\n};\n\nconst playbackStatuses = [\n constants.PLAYBACK_STATUS_PLAYING,\n constants.PLAYBACK_STATUS_PAUSED,\n constants.PLAYBACK_STATUS_STOPPED\n];\n\nconst loopStatuses = [\n constants.LOOP_STATUS_NONE,\n constants.LOOP_STATUS_PLAYLIST,\n constants.LOOP_STATUS_TRACK\n];\n\nconstants.isLoopStatusValid = function(value) {\n return loopStatuses.includes(value);\n};\n\nconstants.isPlaybackStatusValid = function(value) {\n return playbackStatuses.includes(value);\n};\n\nmodule.exports = constants;\n"],"mappings":";;AAAA,MAAMA,SAAS,GAAG;EAChBC,uBAAuB,EAAE,SAAS;EAClCC,sBAAsB,EAAE,QAAQ;EAChCC,uBAAuB,EAAE,SAAS;EAElCC,gBAAgB,EAAE,MAAM;EACxBC,iBAAiB,EAAE,OAAO;EAC1BC,oBAAoB,EAAE;AACxB,CAAC;AAED,MAAMC,gBAAgB,GAAG,CACvBP,SAAS,CAACC,uBAAuB,EACjCD,SAAS,CAACE,sBAAsB,EAChCF,SAAS,CAACG,uBAAuB,CAClC;AAED,MAAMK,YAAY,GAAG,CACnBR,SAAS,CAACI,gBAAgB,EAC1BJ,SAAS,CAACM,oBAAoB,EAC9BN,SAAS,CAACK,iBAAiB,CAC5B;AAEDL,SAAS,CAACS,iBAAiB,GAAG,UAASC,KAAK,EAAE;EAC5C,OAAOF,YAAY,CAACG,QAAQ,CAACD,KAAK,CAAC;AACrC,CAAC;AAEDV,SAAS,CAACY,qBAAqB,GAAG,UAASF,KAAK,EAAE;EAChD,OAAOH,gBAAgB,CAACI,QAAQ,CAACD,KAAK,CAAC;AACzC,CAAC;AAEDG,MAAM,CAACC,OAAO,GAAGd,SAAS","ignoreList":[]}
|
package/dist/index.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
function _defineProperty(
|
|
4
|
-
function _toPropertyKey(
|
|
5
|
-
function _toPrimitive(
|
|
6
|
-
function _classPrivateMethodInitSpec(
|
|
7
|
-
function _checkPrivateRedeclaration(
|
|
8
|
-
function
|
|
3
|
+
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
4
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
5
|
+
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
6
|
+
function _classPrivateMethodInitSpec(e, a) { _checkPrivateRedeclaration(e, a), a.add(e); }
|
|
7
|
+
function _checkPrivateRedeclaration(e, t) { if (t.has(e)) throw new TypeError("Cannot initialize the same private elements twice on an object"); }
|
|
8
|
+
function _assertClassBrand(e, t, n) { if ("function" == typeof e ? e === t : e.has(t)) return arguments.length < 3 ? t : n; throw new TypeError("Private element is not present on this object"); }
|
|
9
9
|
require('source-map-support').install();
|
|
10
10
|
const {
|
|
11
11
|
EventEmitter
|
|
12
12
|
} = require('events');
|
|
13
|
-
const dbus = require('dbus-next');
|
|
13
|
+
const dbus = require('@jellybrick/dbus-next');
|
|
14
14
|
const PlayerInterface = require('./interfaces/player');
|
|
15
15
|
const RootInterface = require('./interfaces/root');
|
|
16
16
|
const PlaylistsInterface = require('./interfaces/playlists');
|
|
@@ -21,12 +21,7 @@ const MPRIS_PATH = '/org/mpris/MediaPlayer2';
|
|
|
21
21
|
function lcfirst(str) {
|
|
22
22
|
return str[0].toLowerCase() + str.substring(1);
|
|
23
23
|
}
|
|
24
|
-
var
|
|
25
|
-
var _addPlayerInterface = /*#__PURE__*/new WeakSet();
|
|
26
|
-
var _addTracklistInterface = /*#__PURE__*/new WeakSet();
|
|
27
|
-
var _addPlaylistsInterface = /*#__PURE__*/new WeakSet();
|
|
28
|
-
var _addEventedProperty = /*#__PURE__*/new WeakSet();
|
|
29
|
-
var _addEventedPropertiesList = /*#__PURE__*/new WeakSet();
|
|
24
|
+
var _Player_brand = /*#__PURE__*/new WeakSet();
|
|
30
25
|
class Player extends EventEmitter {
|
|
31
26
|
/**
|
|
32
27
|
* Construct a new Player and export it on the DBus session bus.
|
|
@@ -165,27 +160,22 @@ class Player extends EventEmitter {
|
|
|
165
160
|
* @property {String} loopStatus - The current loop/repeat status. May be "None", "Track", or "Playlist".
|
|
166
161
|
* @property {Boolean} shuffle - Whether the player is shuffling.
|
|
167
162
|
* @property {Object} metadata - The metadata of the current element. If there is a current track, this must have a "mpris:trackid" entry (of D-Bus type "o") at the very least, which contains a D-Bus path that uniquely identifies this track.
|
|
168
|
-
* @property {
|
|
163
|
+
* @property {Number} volume - The volume level. (Double)
|
|
169
164
|
* @property {Boolean} canControl - Whether the media player may be controlled over this interface.
|
|
170
165
|
* @property {Boolean} canPause - Whether playback can be paused using Pause or PlayPause.
|
|
171
166
|
* @property {Boolean} canPlay - Whether playback can be started using Play or PlayPause.
|
|
172
167
|
* @property {Boolean} canSeek - Whether the client can control the playback position using Seek and SetPosition.
|
|
173
168
|
* @property {Boolean} canGoNext - Whether the client can call the Next method on this interface and expect the current track to change.
|
|
174
169
|
* @property {Boolean} canGoPrevious - Whether the client can call the Previous method on this interface and expect the current track to change.
|
|
175
|
-
* @property {
|
|
176
|
-
* @property {
|
|
177
|
-
* @property {
|
|
170
|
+
* @property {Number} rate - The current playback rate. (Double)
|
|
171
|
+
* @property {Number} minimumRate - The minimum value which the Rate property can take. (Double)
|
|
172
|
+
* @property {Number} maximumRate - The maximum value which the Rate property can take. (Double)
|
|
178
173
|
* @property {Array} playlists - The current playlists set by {@link Player#setPlaylists}. (Not a DBus property).
|
|
179
174
|
* @property {String} activePlaylist - The id of the currently-active playlist.
|
|
180
175
|
*/
|
|
181
176
|
constructor(options) {
|
|
182
177
|
super();
|
|
183
|
-
_classPrivateMethodInitSpec(this,
|
|
184
|
-
_classPrivateMethodInitSpec(this, _addEventedProperty);
|
|
185
|
-
_classPrivateMethodInitSpec(this, _addPlaylistsInterface);
|
|
186
|
-
_classPrivateMethodInitSpec(this, _addTracklistInterface);
|
|
187
|
-
_classPrivateMethodInitSpec(this, _addPlayerInterface);
|
|
188
|
-
_classPrivateMethodInitSpec(this, _addRootInterface);
|
|
178
|
+
_classPrivateMethodInitSpec(this, _Player_brand);
|
|
189
179
|
this.name = options.name;
|
|
190
180
|
this.supportedInterfaces = options.supportedInterfaces || ['player'];
|
|
191
181
|
this._tracks = [];
|
|
@@ -199,15 +189,15 @@ class Player extends EventEmitter {
|
|
|
199
189
|
this.emit('error', err);
|
|
200
190
|
});
|
|
201
191
|
this.interfaces = {};
|
|
202
|
-
|
|
192
|
+
_assertClassBrand(_Player_brand, this, _addRootInterface).call(this, this._bus, opts);
|
|
203
193
|
if (this.supportedInterfaces.indexOf('player') >= 0) {
|
|
204
|
-
|
|
194
|
+
_assertClassBrand(_Player_brand, this, _addPlayerInterface).call(this, this._bus);
|
|
205
195
|
}
|
|
206
196
|
if (this.supportedInterfaces.indexOf('trackList') >= 0) {
|
|
207
|
-
|
|
197
|
+
_assertClassBrand(_Player_brand, this, _addTracklistInterface).call(this, this._bus);
|
|
208
198
|
}
|
|
209
199
|
if (this.supportedInterfaces.indexOf('playlists') >= 0) {
|
|
210
|
-
|
|
200
|
+
_assertClassBrand(_Player_brand, this, _addPlaylistsInterface).call(this, this._bus);
|
|
211
201
|
}
|
|
212
202
|
for (let k of Object.keys(this.interfaces)) {
|
|
213
203
|
let iface = this.interfaces[k];
|
|
@@ -244,7 +234,7 @@ class Player extends EventEmitter {
|
|
|
244
234
|
*
|
|
245
235
|
* @name Player#getPosition
|
|
246
236
|
* @function
|
|
247
|
-
* @returns {
|
|
237
|
+
* @returns {Number} - The current position of the player in microseconds. (Integer)
|
|
248
238
|
*/
|
|
249
239
|
getPosition() {
|
|
250
240
|
return 0;
|
|
@@ -255,7 +245,7 @@ class Player extends EventEmitter {
|
|
|
255
245
|
*
|
|
256
246
|
* @name Player#seeked
|
|
257
247
|
* @function
|
|
258
|
-
* @param {
|
|
248
|
+
* @param {Number} position - The position in microseconds. (Integer)
|
|
259
249
|
*/
|
|
260
250
|
seeked(position) {
|
|
261
251
|
let seekTo = Math.floor(position || 0);
|
|
@@ -349,18 +339,18 @@ class Player extends EventEmitter {
|
|
|
349
339
|
* @constant
|
|
350
340
|
*/
|
|
351
341
|
}
|
|
352
|
-
function
|
|
342
|
+
function _addRootInterface(bus, opts) {
|
|
353
343
|
this.interfaces.root = new RootInterface(this, opts);
|
|
354
|
-
|
|
344
|
+
_assertClassBrand(_Player_brand, this, _addEventedPropertiesList).call(this, this.interfaces.root, ['Identity', 'Fullscreen', 'SupportedUriSchemes', 'SupportedMimeTypes', 'CanQuit', 'CanRaise', 'CanSetFullscreen', 'HasTrackList', 'DesktopEntry']);
|
|
355
345
|
}
|
|
356
|
-
function
|
|
346
|
+
function _addPlayerInterface(bus) {
|
|
357
347
|
this.interfaces.player = new PlayerInterface(this);
|
|
358
348
|
let eventedProps = ['PlaybackStatus', 'LoopStatus', 'Rate', 'Shuffle', 'Metadata', 'Volume', 'CanControl', 'CanPause', 'CanPlay', 'CanSeek', 'CanGoNext', 'CanGoPrevious', 'MinimumRate', 'MaximumRate'];
|
|
359
|
-
|
|
349
|
+
_assertClassBrand(_Player_brand, this, _addEventedPropertiesList).call(this, this.interfaces.player, eventedProps);
|
|
360
350
|
}
|
|
361
|
-
function
|
|
351
|
+
function _addTracklistInterface(bus) {
|
|
362
352
|
this.interfaces.tracklist = new TracklistInterface(this);
|
|
363
|
-
|
|
353
|
+
_assertClassBrand(_Player_brand, this, _addEventedPropertiesList).call(this, this.interfaces.tracklist, ['CanEditTracks']);
|
|
364
354
|
Object.defineProperty(this, 'tracks', {
|
|
365
355
|
get: function () {
|
|
366
356
|
return this._tracks;
|
|
@@ -373,11 +363,11 @@ function _addTracklistInterface2(bus) {
|
|
|
373
363
|
configurable: true
|
|
374
364
|
});
|
|
375
365
|
}
|
|
376
|
-
function
|
|
366
|
+
function _addPlaylistsInterface(bus) {
|
|
377
367
|
this.interfaces.playlists = new PlaylistsInterface(this);
|
|
378
|
-
|
|
368
|
+
_assertClassBrand(_Player_brand, this, _addEventedPropertiesList).call(this, this.interfaces.playlists, ['PlaylistCount', 'ActivePlaylist']);
|
|
379
369
|
}
|
|
380
|
-
function
|
|
370
|
+
function _addEventedProperty(iface, name) {
|
|
381
371
|
let localName = lcfirst(name);
|
|
382
372
|
Object.defineProperty(this, localName, {
|
|
383
373
|
get: function () {
|
|
@@ -396,9 +386,9 @@ function _addEventedProperty2(iface, name) {
|
|
|
396
386
|
configurable: true
|
|
397
387
|
});
|
|
398
388
|
}
|
|
399
|
-
function
|
|
389
|
+
function _addEventedPropertiesList(iface, props) {
|
|
400
390
|
for (let i = 0; i < props.length; i++) {
|
|
401
|
-
|
|
391
|
+
_assertClassBrand(_Player_brand, this, _addEventedProperty).call(this, iface, props[i]);
|
|
402
392
|
}
|
|
403
393
|
}
|
|
404
394
|
_defineProperty(Player, "PLAYBACK_STATUS_PLAYING", constants.PLAYBACK_STATUS_PLAYING);
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["require","install","EventEmitter","dbus","PlayerInterface","RootInterface","PlaylistsInterface","TracklistInterface","types","constants","MPRIS_PATH","lcfirst","str","toLowerCase","substring","_addRootInterface","WeakSet","_addPlayerInterface","_addTracklistInterface","_addPlaylistsInterface","_addEventedProperty","_addEventedPropertiesList","Player","constructor","options","_classPrivateMethodInitSpec","name","supportedInterfaces","_tracks","init","opts","serviceName","validators","assertBusNameValid","_bus","sessionBus","on","err","emit","interfaces","_classPrivateMethodGet","_addRootInterface2","call","indexOf","_addPlayerInterface2","_addTracklistInterface2","_addPlaylistsInterface2","k","Object","keys","iface","export","requestName","NameFlag","DO_NOT_QUEUE","then","reply","RequestNameReply","EXISTS","process","pid","catch","objectPath","subpath","path","getPosition","seeked","position","seekTo","Math","floor","isNaN","Error","player","Seeked","getTrackIndex","trackId","i","tracks","length","track","getTrack","addTrack","push","tracklist","setTracks","afterTrack","TrackAdded","removeTrack","splice","TrackRemoved","getPlaylistIndex","playlistId","playlists","playlist","Id","setPlaylists","playlistCount","forEach","PlaylistChanged","setActivePlaylist","setActivePlaylistId","bus","root","_addEventedPropertiesList2","eventedProps","defineProperty","get","set","value","TrackListReplaced","enumerable","configurable","_addEventedProperty2","localName","playlistToPlain","metadataToPlain","setProperty","props","_defineProperty","PLAYBACK_STATUS_PLAYING","PLAYBACK_STATUS_PAUSED","PLAYBACK_STATUS_STOPPED","LOOP_STATUS_NONE","LOOP_STATUS_TRACK","LOOP_STATUS_PLAYLIST","module","exports"],"sourceRoot":"../src/","sources":["index.js"],"sourcesContent":["require('source-map-support').install();\n\nconst { EventEmitter } = require('events');\n\nconst dbus = require('dbus-next');\nconst PlayerInterface = require('./interfaces/player');\nconst RootInterface = require('./interfaces/root');\nconst PlaylistsInterface = require('./interfaces/playlists');\nconst TracklistInterface = require('./interfaces/tracklist');\nconst types = require('./interfaces/types');\nconst constants = require('./constants');\n\nconst MPRIS_PATH = '/org/mpris/MediaPlayer2';\n\nfunction lcfirst(str) {\n return str[0].toLowerCase() + str.substring(1);\n}\n\nclass Player extends EventEmitter {\n /**\n * Construct a new Player and export it on the DBus session bus.\n *\n * For more information about the properties of this class, see [the MPRIS DBus Interface Specification](https://specifications.freedesktop.org/mpris-spec/latest/).\n *\n * Method Call Events\n * ------------------\n *\n * The Player is an `EventEmitter` that emits events when the corresponding\n * methods are called on the DBus interface over the wire.\n *\n * The Player emits events whenever the corresponding methods on the DBus\n * interface are called.\n *\n * * `raise` - Brings the media player's user interface to the front using any appropriate mechanism available.\n * * `quit` - Causes the media player to stop running.\n * * `next` - Skips to the next track in the tracklist.\n * * `previous` - Skips to the previous track in the tracklist.\n * * `pause` - Pauses playback.\n * * `playPause` - Pauses playback. If playback is already paused, resumes playback. If playback is stopped, starts playback.\n * * `stop` - Stops playback.\n * * `play` - Starts or resumes playback.\n * * `seek` - Seeks forward in the current track by the specified number of microseconds. With event data `offset`.\n * * `position` - Sets the current track position in microseconds. With event data `{ trackId, position }`.\n * * `open` - Opens the Uri given as an argument. With event data `{ uri }`.\n * * `volume` - Sets the volume of the player. With event data `volume` (between 0.0 and 1.0).\n * * `shuffle` - Sets whether shuffle is enabled on the player. With event data `shuffleStatus` (boolean).\n * * `rate` - Sets the playback rate of the player. A value of 1.0 is the normal rate. With event data `rate`.\n * * `loopStatus` - Sets the loop status of the player to either 'None', 'Track', or 'Playlist'. With event data `loopStatus`.\n * * `activatePlaylist` - Starts playing the given playlist. With event data `playlistId`.\n *\n * The Player may also emit an `error` event with the underlying Node `Error`\n * as the event data. After receiving this event, the Player may be\n * disconnected.\n *\n * ```\n * player.on('play', () => {\n * realPlayer.play();\n * });\n *\n * player.on('shuffle', (enableShuffle) => {\n * realPlayer.setShuffle(enableShuffle);\n * player.shuffle = enableShuffle;\n * });\n * ```\n *\n * Player Properties\n * -----------------\n *\n * Player properties (documented below) should be kept up to date to reflect\n * the state of your real player. These properties can be gotten by the client\n * through the `org.freedesktop.DBus.Properties` interface which will return\n * the value currently set on the player. Setting these properties on the\n * player to a different value will emit the `PropertiesChanged` signal on the\n * properties interface to notify clients that properties of the player have\n * changed.\n *\n * ```\n * realPlayer.on('shuffle:changed', (shuffleEnabled) => {\n * player.shuffle = shuffleEnabled;\n * });\n *\n * realPlayer.on('play', () => {\n * player.playbackStatus = 'Playing';\n * });\n * ```\n *\n * Player Position\n * ---------------\n *\n * Clients can get the position of your player by getting the `Position`\n * property of the `org.mpris.MediaPlayer2.Player` interface. Since position\n * updates continuously, {@link Player#getPosition} is implemented as a getter\n * you can override on your Player. This getter will be called when a client\n * requests the position and should return the position of your player for the\n * client in microseconds.\n *\n * ```\n * player.getPosition() {\n * return realPlayer.getPositionInMicroseconds();\n * }\n * ```\n *\n * When your real player seeks to a new location, such as when someone clicks\n * on the time bar, you can notify clients of the new position by calling the\n * {@link Player#seeked} method. This will raise the `Seeked` signal on the\n * `org.mpris.MediaPlayer2.Player` interface with the given current time of the\n * player in microseconds.\n *\n * ```\n * realPlayer.on('seeked', (positionInMicroseconds) => {\n * player.seeked(positionInMicroseconds);\n * });\n * ```\n *\n * Clients can request to set position using the `Seek` and `SetPosition`\n * methods of the `org.mpris.MediaPlayer2.Player` interface. These requests are\n * implemented as events on the Player similar to the other requests.\n *\n * ```\n * player.on('seek', (offset) => {\n * // note that offset may be negative\n * let currentPosition = realPlayer.getPositionInMicroseconds();\n * let newPosition = currentPosition + offset;\n * realPlayer.setPosition(newPosition);\n * });\n *\n * player.on('position', (event) => {\n * // check that event.trackId is the current track before continuing.\n * realPlayer.setPosition(event.position);\n * });\n * ```\n *\n * @class Player\n * @param {\n * name: String,\n * identity: String,\n * supportedMimeTypes: string[],\n * supportedInterfaces: string[]\n * } options - Options for the player.\n * @param {String} options.name - Name on the bus to export to as `org.mpris.MediaPlayer2.{name}`.\n * @param {String} options.identity - Identity for the player to display on the root media player interface.\n * @param {Array} options.supportedMimeTypes - Mime types this player can open with the `org.mpris.MediaPlayer2.Open` method.\n * @param {Array} options.supportedInterfaces - The interfaces this player supports. Can include `'player'`, `'playlists'`, and `'trackList'`.\n * @property {String} identity - A friendly name to identify the media player to users.\n * @property {Boolean} fullscreen - Whether the media player is occupying the fullscreen.\n * @property {Array} supportedUriSchemes - The URI schemes supported by the media player.\n * @property {Array} supportedMimeTypes - The mime-types supported by the media player.\n * @property {Boolean} canQuit - Whether the player can quit.\n * @property {Boolean} canRaise - Whether the player can raise.\n * @property {Boolean} canSetFullscreen - Whether the player can be set to fullscreen.\n * @property {Boolean} hasTrackList - Indicates whether the /org/mpris/MediaPlayer2 object implements the org.mpris.MediaPlayer2.TrackList interface.\n * @property {String} desktopEntry - The basename of an installed .desktop file which complies with the Desktop entry specification, with the \".desktop\" extension stripped.\n * @property {String} playbackStatus - The current playback status. May be \"Playing\", \"Paused\" or \"Stopped\".\n * @property {String} loopStatus - The current loop/repeat status. May be \"None\", \"Track\", or \"Playlist\".\n * @property {Boolean} shuffle - Whether the player is shuffling.\n * @property {Object} metadata - The metadata of the current element. If there is a current track, this must have a \"mpris:trackid\" entry (of D-Bus type \"o\") at the very least, which contains a D-Bus path that uniquely identifies this track.\n * @property {Double} volume - The volume level.\n * @property {Boolean} canControl - Whether the media player may be controlled over this interface.\n * @property {Boolean} canPause - Whether playback can be paused using Pause or PlayPause.\n * @property {Boolean} canPlay - Whether playback can be started using Play or PlayPause.\n * @property {Boolean} canSeek - Whether the client can control the playback position using Seek and SetPosition.\n * @property {Boolean} canGoNext - Whether the client can call the Next method on this interface and expect the current track to change.\n * @property {Boolean} canGoPrevious - Whether the client can call the Previous method on this interface and expect the current track to change.\n * @property {Double} rate - The current playback rate.\n * @property {Double} minimumRate - The minimum value which the Rate property can take.\n * @property {Double} maximumRate - The maximum value which the Rate property can take.\n * @property {Array} playlists - The current playlists set by {@link Player#setPlaylists}. (Not a DBus property).\n * @property {String} activePlaylist - The id of the currently-active playlist.\n */\n constructor(options) {\n super();\n\n this.name = options.name;\n this.supportedInterfaces = options.supportedInterfaces || ['player'];\n this._tracks = [];\n this.init(options);\n }\n\n init(opts) {\n this.serviceName = `org.mpris.MediaPlayer2.${this.name}`;\n dbus.validators.assertBusNameValid(this.serviceName);\n\n this._bus = dbus.sessionBus();\n\n this._bus.on('error', (err) => {\n this.emit('error', err);\n });\n\n this.interfaces = {};\n\n this.#addRootInterface(this._bus, opts);\n\n if (this.supportedInterfaces.indexOf('player') >= 0) {\n this.#addPlayerInterface(this._bus);\n }\n if (this.supportedInterfaces.indexOf('trackList') >= 0) {\n this.#addTracklistInterface(this._bus);\n }\n if (this.supportedInterfaces.indexOf('playlists') >= 0) {\n this.#addPlaylistsInterface(this._bus);\n }\n\n for (let k of Object.keys(this.interfaces)) {\n let iface = this.interfaces[k];\n this._bus.export(MPRIS_PATH, iface);\n }\n\n this._bus.requestName(this.serviceName, dbus.NameFlag.DO_NOT_QUEUE)\n .then((reply) => {\n if (reply === dbus.RequestNameReply.EXISTS) {\n this.serviceName = `${this.serviceName}.instance${process.pid}`;\n return this._bus.requestName(this.serviceName);\n }\n })\n .catch((err) => {\n this.emit('error', err);\n });\n }\n\n #addRootInterface(bus, opts) {\n this.interfaces.root = new RootInterface(this, opts);\n this.#addEventedPropertiesList(this.interfaces.root,\n ['Identity', 'Fullscreen', 'SupportedUriSchemes', 'SupportedMimeTypes',\n 'CanQuit', 'CanRaise', 'CanSetFullscreen', 'HasTrackList',\n 'DesktopEntry']);\n }\n\n #addPlayerInterface(bus) {\n this.interfaces.player = new PlayerInterface(this);\n let eventedProps = ['PlaybackStatus', 'LoopStatus', 'Rate', 'Shuffle',\n 'Metadata', 'Volume', 'CanControl', 'CanPause', 'CanPlay', 'CanSeek',\n 'CanGoNext', 'CanGoPrevious', 'MinimumRate', 'MaximumRate'];\n this.#addEventedPropertiesList(this.interfaces.player, eventedProps);\n }\n\n #addTracklistInterface(bus) {\n this.interfaces.tracklist = new TracklistInterface(this);\n this.#addEventedPropertiesList(this.interfaces.tracklist, ['CanEditTracks']);\n\n Object.defineProperty(this, 'tracks', {\n get: function() {\n return this._tracks;\n },\n set: function(value) {\n this._tracks = value;\n this.interfaces.tracklist.TrackListReplaced(value);\n },\n enumerable: true,\n configurable: true\n });\n }\n\n #addPlaylistsInterface(bus) {\n this.interfaces.playlists = new PlaylistsInterface(this);\n this.#addEventedPropertiesList(this.interfaces.playlists,\n ['PlaylistCount', 'ActivePlaylist']);\n }\n\n /**\n * Get a valid object path with the `subpath` as the basename which is suitable\n * for use as an id.\n *\n * @name Player#objectPath\n * @function\n * @param {String} subpath - The basename of this path\n * @returns {String} - A valid object path that can be used as an id.\n */\n objectPath(subpath) {\n let path = `/org/node/mediaplayer/${this.name}`;\n if (subpath) {\n path += `/${subpath}`;\n }\n return path;\n }\n\n #addEventedProperty(iface, name) {\n let localName = lcfirst(name);\n\n Object.defineProperty(this, localName, {\n get: function() {\n let value = iface[name];\n if (name === 'ActivePlaylist') {\n return types.playlistToPlain(value);\n } else if (name === 'Metadata') {\n return types.metadataToPlain(value);\n }\n return value;\n },\n set: function(value) {\n iface.setProperty(name, value);\n },\n enumerable: true,\n configurable: true\n });\n }\n\n #addEventedPropertiesList(iface, props) {\n for (let i = 0; i < props.length; i++) {\n this.#addEventedProperty(iface, props[i]);\n }\n }\n\n /**\n * Gets the position of this player. This method is intended to be overridden\n * by the user to return the position of the player in microseconds.\n *\n * @name Player#getPosition\n * @function\n * @returns {Integer} - The current position of the player in microseconds.\n */\n getPosition() {\n return 0;\n }\n\n /**\n * Emits the `Seeked` DBus signal to listening clients with the given position.\n *\n * @name Player#seeked\n * @function\n * @param {Integer} position - The position in microseconds.\n */\n seeked(position) {\n let seekTo = Math.floor(position || 0);\n if (isNaN(seekTo)) {\n throw new Error(`seeked expected a number (got ${position})`);\n }\n this.interfaces.player.Seeked(seekTo);\n }\n\n getTrackIndex(trackId) {\n for (let i = 0; i < this.tracks.length; i++) {\n let track = this.tracks[i];\n\n if (track['mpris:trackid'] === trackId) {\n return i;\n }\n }\n\n return -1;\n }\n\n getTrack(trackId) {\n return this.tracks[this.getTrackIndex(trackId)];\n }\n\n addTrack(track) {\n this.tracks.push(track);\n this.interfaces.tracklist.setTracks(this.tracks);\n\n let afterTrack = '/org/mpris/MediaPlayer2/TrackList/NoTrack';\n if (this.tracks.length > 2) {\n afterTrack = this.tracks[this.tracks.length - 2]['mpris:trackid'];\n }\n this.interfaces.tracklist.TrackAdded(afterTrack);\n }\n\n removeTrack(trackId) {\n let i = this.getTrackIndex(trackId);\n this.tracks.splice(i, 1);\n this.interfaces.tracklist.setTracks(this.tracks);\n\n this.interfaces.tracklist.TrackRemoved(trackId);\n }\n\n /**\n * Get the index of a playlist entry in the `playlists` list property of the\n * player from the given id.\n *\n * @name Player#getPlaylistIndex\n * @function\n * @param {String} playlistId - The id for the playlist entry.\n */\n getPlaylistIndex(playlistId) {\n for (let i = 0; i < this.playlists.length; i++) {\n let playlist = this.playlists[i];\n\n if (playlist.Id === playlistId) {\n return i;\n }\n }\n\n return -1;\n }\n\n /**\n * Set the list of playlists advertised to listeners on the bus. Each playlist\n * must have string members `Id`, `Name`, and `Icon`.\n *\n * @name Player#setPlaylists\n * @function\n * @param {Array} playlists - A list of playlists.\n */\n setPlaylists(playlists) {\n this.playlists = playlists;\n this.playlistCount = playlists.length;\n\n this.playlists.forEach((playlist) => {\n if (playlist) {\n this.interfaces.playlists.PlaylistChanged(playlist);\n }\n });\n }\n\n /**\n * Set the playlist identified by `playlistId` to be the currently active\n * playlist.\n *\n * @name Player#setActivePlaylist\n * @function\n * @param {String} playlistId - The id of the playlist to activate.\n */\n setActivePlaylist(playlistId) {\n this.interfaces.playlists.setActivePlaylistId(playlistId);\n }\n\n /**\n * Enumerated value for the `playbackStatus` property of the player to indicate\n * a track is currently playing.\n *\n * @name Player#PLAYBACK_STATUS_PLAYING\n * @static\n * @constant\n */\n static PLAYBACK_STATUS_PLAYING = constants.PLAYBACK_STATUS_PLAYING;\n /**\n * Enumerated value for the `playbackStatus` property of the player to indicate\n * a track is currently paused.\n *\n * @name Player#PLAYBACK_STATUS_PAUSED\n * @static\n * @constant\n */\n static PLAYBACK_STATUS_PAUSED = constants.PLAYBACK_STATUS_PAUSED;\n\n /**\n * Enumerated value for the `playbackStatus` property of the player to indicate\n * there is no track currently playing.\n *\n * @name Player#PLAYBACK_STATUS_STOPPED\n * @static\n * @constant\n */\n static PLAYBACK_STATUS_STOPPED = constants.PLAYBACK_STATUS_STOPPED;\n\n /**\n * Enumerated value for the `loopStatus` property of the player to indicate\n * playback will stop when there are no more tracks to play.\n *\n * @name Player#LOOP_STATUS_NONE\n * @static\n * @constant\n */\n static LOOP_STATUS_NONE = constants.LOOP_STATUS_NONE;\n\n /**\n * Enumerated value for the `loopStatus` property of the player to indicate the\n * current track will start again from the beginning once it has finished\n * playing.\n *\n * @name Player#LOOP_STATUS_TRACK\n * @static\n * @constant\n */\n static LOOP_STATUS_TRACK = constants.LOOP_STATUS_TRACK;\n\n /**\n * Enumerated value for the `loopStatus` property of the player to indicate the\n * playback loops through a list of tracks.\n *\n * @name Player#LOOP_STATUS_PLAYLIST\n * @static\n * @constant\n */\n static LOOP_STATUS_PLAYLIST = constants.LOOP_STATUS_PLAYLIST;\n}\n\nmodule.exports = Player;"],"mappings":";;;;;;;;AAAAA,OAAO,CAAC,oBAAoB,CAAC,CAACC,OAAO,CAAC,CAAC;AAEvC,MAAM;EAAEC;AAAa,CAAC,GAAGF,OAAO,CAAC,QAAQ,CAAC;AAE1C,MAAMG,IAAI,GAAGH,OAAO,CAAC,WAAW,CAAC;AACjC,MAAMI,eAAe,GAAGJ,OAAO,CAAC,qBAAqB,CAAC;AACtD,MAAMK,aAAa,GAAGL,OAAO,CAAC,mBAAmB,CAAC;AAClD,MAAMM,kBAAkB,GAAGN,OAAO,CAAC,wBAAwB,CAAC;AAC5D,MAAMO,kBAAkB,GAAGP,OAAO,CAAC,wBAAwB,CAAC;AAC5D,MAAMQ,KAAK,GAAGR,OAAO,CAAC,oBAAoB,CAAC;AAC3C,MAAMS,SAAS,GAAGT,OAAO,CAAC,aAAa,CAAC;AAExC,MAAMU,UAAU,GAAG,yBAAyB;AAE5C,SAASC,OAAOA,CAACC,GAAG,EAAE;EACpB,OAAOA,GAAG,CAAC,CAAC,CAAC,CAACC,WAAW,CAAC,CAAC,GAAGD,GAAG,CAACE,SAAS,CAAC,CAAC,CAAC;AAChD;AAAC,IAAAC,iBAAA,oBAAAC,OAAA;AAAA,IAAAC,mBAAA,oBAAAD,OAAA;AAAA,IAAAE,sBAAA,oBAAAF,OAAA;AAAA,IAAAG,sBAAA,oBAAAH,OAAA;AAAA,IAAAI,mBAAA,oBAAAJ,OAAA;AAAA,IAAAK,yBAAA,oBAAAL,OAAA;AAED,MAAMM,MAAM,SAASpB,YAAY,CAAC;EAChC;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACEqB,WAAWA,CAACC,OAAO,EAAE;IACnB,KAAK,CAAC,CAAC;IAACC,2BAAA,OAAAJ,yBAAA;IAAAI,2BAAA,OAAAL,mBAAA;IAAAK,2BAAA,OAAAN,sBAAA;I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AAAR,2BAEyBtD,KAAK,EAAEoE,KAAK,EAAE;EACtC,KAAK,IAAIzC,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGyC,KAAK,CAACvC,MAAM,EAAEF,CAAC,EAAE,EAAE;IACrCrC,sBAAA,KAAI,EAAApB,mBAAA,EAAA6F,oBAAA,EAAAvE,IAAA,CAAJ,IAAI,EAAqBQ,KAAK,EAAEoE,KAAK,CAACzC,CAAC,CAAC;EAC1C;AACF;AAAC0C,eAAA,CA1RGjG,MAAM,6BAqZuBb,SAAS,CAAC+G,uBAAuB;AAClE;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AAPED,eAAA,CAtZIjG,MAAM,4BA8ZsBb,SAAS,CAACgH,sBAAsB;AAEhE;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AAPEF,eAAA,CAhaIjG,MAAM,6BAwauBb,SAAS,CAACiH,uBAAuB;AAElE;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AAPEH,eAAA,CA1aIjG,MAAM,sBAkbgBb,SAAS,CAACkH,gBAAgB;AAEpD;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAREJ,eAAA,CApbIjG,MAAM,uBA6biBb,SAAS,CAACmH,iBAAiB;AAEtD;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AAPEL,eAAA,CA/bIjG,MAAM,0BAucoBb,SAAS,CAACoH,oBAAoB;AAG9DC,MAAM,CAACC,OAAO,GAAGzG,MAAM"}
|
|
1
|
+
{"version":3,"file":"index.js","names":["require","install","EventEmitter","dbus","PlayerInterface","RootInterface","PlaylistsInterface","TracklistInterface","types","constants","MPRIS_PATH","lcfirst","str","toLowerCase","substring","_Player_brand","WeakSet","Player","constructor","options","_classPrivateMethodInitSpec","name","supportedInterfaces","_tracks","init","opts","serviceName","validators","assertBusNameValid","_bus","sessionBus","on","err","emit","interfaces","_assertClassBrand","_addRootInterface","call","indexOf","_addPlayerInterface","_addTracklistInterface","_addPlaylistsInterface","k","Object","keys","iface","export","requestName","NameFlag","DO_NOT_QUEUE","then","reply","RequestNameReply","EXISTS","process","pid","catch","objectPath","subpath","path","getPosition","seeked","position","seekTo","Math","floor","isNaN","Error","player","Seeked","getTrackIndex","trackId","i","tracks","length","track","getTrack","addTrack","push","tracklist","setTracks","afterTrack","TrackAdded","removeTrack","splice","TrackRemoved","getPlaylistIndex","playlistId","playlists","playlist","Id","setPlaylists","playlistCount","forEach","PlaylistChanged","setActivePlaylist","setActivePlaylistId","bus","root","_addEventedPropertiesList","eventedProps","defineProperty","get","set","value","TrackListReplaced","enumerable","configurable","_addEventedProperty","localName","playlistToPlain","metadataToPlain","setProperty","props","_defineProperty","PLAYBACK_STATUS_PLAYING","PLAYBACK_STATUS_PAUSED","PLAYBACK_STATUS_STOPPED","LOOP_STATUS_NONE","LOOP_STATUS_TRACK","LOOP_STATUS_PLAYLIST","module","exports"],"sourceRoot":"../src/","sources":["index.js"],"sourcesContent":["require('source-map-support').install();\n\nconst { EventEmitter } = require('events');\n\nconst dbus = require('@jellybrick/dbus-next');\nconst PlayerInterface = require('./interfaces/player');\nconst RootInterface = require('./interfaces/root');\nconst PlaylistsInterface = require('./interfaces/playlists');\nconst TracklistInterface = require('./interfaces/tracklist');\nconst types = require('./interfaces/types');\nconst constants = require('./constants');\n\nconst MPRIS_PATH = '/org/mpris/MediaPlayer2';\n\nfunction lcfirst(str) {\n return str[0].toLowerCase() + str.substring(1);\n}\n\nclass Player extends EventEmitter {\n /**\n * Construct a new Player and export it on the DBus session bus.\n *\n * For more information about the properties of this class, see [the MPRIS DBus Interface Specification](https://specifications.freedesktop.org/mpris-spec/latest/).\n *\n * Method Call Events\n * ------------------\n *\n * The Player is an `EventEmitter` that emits events when the corresponding\n * methods are called on the DBus interface over the wire.\n *\n * The Player emits events whenever the corresponding methods on the DBus\n * interface are called.\n *\n * * `raise` - Brings the media player's user interface to the front using any appropriate mechanism available.\n * * `quit` - Causes the media player to stop running.\n * * `next` - Skips to the next track in the tracklist.\n * * `previous` - Skips to the previous track in the tracklist.\n * * `pause` - Pauses playback.\n * * `playPause` - Pauses playback. If playback is already paused, resumes playback. If playback is stopped, starts playback.\n * * `stop` - Stops playback.\n * * `play` - Starts or resumes playback.\n * * `seek` - Seeks forward in the current track by the specified number of microseconds. With event data `offset`.\n * * `position` - Sets the current track position in microseconds. With event data `{ trackId, position }`.\n * * `open` - Opens the Uri given as an argument. With event data `{ uri }`.\n * * `volume` - Sets the volume of the player. With event data `volume` (between 0.0 and 1.0).\n * * `shuffle` - Sets whether shuffle is enabled on the player. With event data `shuffleStatus` (boolean).\n * * `rate` - Sets the playback rate of the player. A value of 1.0 is the normal rate. With event data `rate`.\n * * `loopStatus` - Sets the loop status of the player to either 'None', 'Track', or 'Playlist'. With event data `loopStatus`.\n * * `activatePlaylist` - Starts playing the given playlist. With event data `playlistId`.\n *\n * The Player may also emit an `error` event with the underlying Node `Error`\n * as the event data. After receiving this event, the Player may be\n * disconnected.\n *\n * ```\n * player.on('play', () => {\n * realPlayer.play();\n * });\n *\n * player.on('shuffle', (enableShuffle) => {\n * realPlayer.setShuffle(enableShuffle);\n * player.shuffle = enableShuffle;\n * });\n * ```\n *\n * Player Properties\n * -----------------\n *\n * Player properties (documented below) should be kept up to date to reflect\n * the state of your real player. These properties can be gotten by the client\n * through the `org.freedesktop.DBus.Properties` interface which will return\n * the value currently set on the player. Setting these properties on the\n * player to a different value will emit the `PropertiesChanged` signal on the\n * properties interface to notify clients that properties of the player have\n * changed.\n *\n * ```\n * realPlayer.on('shuffle:changed', (shuffleEnabled) => {\n * player.shuffle = shuffleEnabled;\n * });\n *\n * realPlayer.on('play', () => {\n * player.playbackStatus = 'Playing';\n * });\n * ```\n *\n * Player Position\n * ---------------\n *\n * Clients can get the position of your player by getting the `Position`\n * property of the `org.mpris.MediaPlayer2.Player` interface. Since position\n * updates continuously, {@link Player#getPosition} is implemented as a getter\n * you can override on your Player. This getter will be called when a client\n * requests the position and should return the position of your player for the\n * client in microseconds.\n *\n * ```\n * player.getPosition() {\n * return realPlayer.getPositionInMicroseconds();\n * }\n * ```\n *\n * When your real player seeks to a new location, such as when someone clicks\n * on the time bar, you can notify clients of the new position by calling the\n * {@link Player#seeked} method. This will raise the `Seeked` signal on the\n * `org.mpris.MediaPlayer2.Player` interface with the given current time of the\n * player in microseconds.\n *\n * ```\n * realPlayer.on('seeked', (positionInMicroseconds) => {\n * player.seeked(positionInMicroseconds);\n * });\n * ```\n *\n * Clients can request to set position using the `Seek` and `SetPosition`\n * methods of the `org.mpris.MediaPlayer2.Player` interface. These requests are\n * implemented as events on the Player similar to the other requests.\n *\n * ```\n * player.on('seek', (offset) => {\n * // note that offset may be negative\n * let currentPosition = realPlayer.getPositionInMicroseconds();\n * let newPosition = currentPosition + offset;\n * realPlayer.setPosition(newPosition);\n * });\n *\n * player.on('position', (event) => {\n * // check that event.trackId is the current track before continuing.\n * realPlayer.setPosition(event.position);\n * });\n * ```\n *\n * @class Player\n * @param {\n * name: String,\n * identity: String,\n * supportedMimeTypes: string[],\n * supportedInterfaces: string[]\n * } options - Options for the player.\n * @param {String} options.name - Name on the bus to export to as `org.mpris.MediaPlayer2.{name}`.\n * @param {String} options.identity - Identity for the player to display on the root media player interface.\n * @param {Array} options.supportedMimeTypes - Mime types this player can open with the `org.mpris.MediaPlayer2.Open` method.\n * @param {Array} options.supportedInterfaces - The interfaces this player supports. Can include `'player'`, `'playlists'`, and `'trackList'`.\n * @property {String} identity - A friendly name to identify the media player to users.\n * @property {Boolean} fullscreen - Whether the media player is occupying the fullscreen.\n * @property {Array} supportedUriSchemes - The URI schemes supported by the media player.\n * @property {Array} supportedMimeTypes - The mime-types supported by the media player.\n * @property {Boolean} canQuit - Whether the player can quit.\n * @property {Boolean} canRaise - Whether the player can raise.\n * @property {Boolean} canSetFullscreen - Whether the player can be set to fullscreen.\n * @property {Boolean} hasTrackList - Indicates whether the /org/mpris/MediaPlayer2 object implements the org.mpris.MediaPlayer2.TrackList interface.\n * @property {String} desktopEntry - The basename of an installed .desktop file which complies with the Desktop entry specification, with the \".desktop\" extension stripped.\n * @property {String} playbackStatus - The current playback status. May be \"Playing\", \"Paused\" or \"Stopped\".\n * @property {String} loopStatus - The current loop/repeat status. May be \"None\", \"Track\", or \"Playlist\".\n * @property {Boolean} shuffle - Whether the player is shuffling.\n * @property {Object} metadata - The metadata of the current element. If there is a current track, this must have a \"mpris:trackid\" entry (of D-Bus type \"o\") at the very least, which contains a D-Bus path that uniquely identifies this track.\n * @property {Number} volume - The volume level. (Double)\n * @property {Boolean} canControl - Whether the media player may be controlled over this interface.\n * @property {Boolean} canPause - Whether playback can be paused using Pause or PlayPause.\n * @property {Boolean} canPlay - Whether playback can be started using Play or PlayPause.\n * @property {Boolean} canSeek - Whether the client can control the playback position using Seek and SetPosition.\n * @property {Boolean} canGoNext - Whether the client can call the Next method on this interface and expect the current track to change.\n * @property {Boolean} canGoPrevious - Whether the client can call the Previous method on this interface and expect the current track to change.\n * @property {Number} rate - The current playback rate. (Double)\n * @property {Number} minimumRate - The minimum value which the Rate property can take. (Double)\n * @property {Number} maximumRate - The maximum value which the Rate property can take. (Double)\n * @property {Array} playlists - The current playlists set by {@link Player#setPlaylists}. (Not a DBus property).\n * @property {String} activePlaylist - The id of the currently-active playlist.\n */\n constructor(options) {\n super();\n\n this.name = options.name;\n this.supportedInterfaces = options.supportedInterfaces || ['player'];\n this._tracks = [];\n this.init(options);\n }\n\n init(opts) {\n this.serviceName = `org.mpris.MediaPlayer2.${this.name}`;\n dbus.validators.assertBusNameValid(this.serviceName);\n\n this._bus = dbus.sessionBus();\n\n this._bus.on('error', (err) => {\n this.emit('error', err);\n });\n\n this.interfaces = {};\n\n this.#addRootInterface(this._bus, opts);\n\n if (this.supportedInterfaces.indexOf('player') >= 0) {\n this.#addPlayerInterface(this._bus);\n }\n if (this.supportedInterfaces.indexOf('trackList') >= 0) {\n this.#addTracklistInterface(this._bus);\n }\n if (this.supportedInterfaces.indexOf('playlists') >= 0) {\n this.#addPlaylistsInterface(this._bus);\n }\n\n for (let k of Object.keys(this.interfaces)) {\n let iface = this.interfaces[k];\n this._bus.export(MPRIS_PATH, iface);\n }\n\n this._bus.requestName(this.serviceName, dbus.NameFlag.DO_NOT_QUEUE)\n .then((reply) => {\n if (reply === dbus.RequestNameReply.EXISTS) {\n this.serviceName = `${this.serviceName}.instance${process.pid}`;\n return this._bus.requestName(this.serviceName);\n }\n })\n .catch((err) => {\n this.emit('error', err);\n });\n }\n\n #addRootInterface(bus, opts) {\n this.interfaces.root = new RootInterface(this, opts);\n this.#addEventedPropertiesList(this.interfaces.root,\n ['Identity', 'Fullscreen', 'SupportedUriSchemes', 'SupportedMimeTypes',\n 'CanQuit', 'CanRaise', 'CanSetFullscreen', 'HasTrackList',\n 'DesktopEntry']);\n }\n\n #addPlayerInterface(bus) {\n this.interfaces.player = new PlayerInterface(this);\n let eventedProps = ['PlaybackStatus', 'LoopStatus', 'Rate', 'Shuffle',\n 'Metadata', 'Volume', 'CanControl', 'CanPause', 'CanPlay', 'CanSeek',\n 'CanGoNext', 'CanGoPrevious', 'MinimumRate', 'MaximumRate'];\n this.#addEventedPropertiesList(this.interfaces.player, eventedProps);\n }\n\n #addTracklistInterface(bus) {\n this.interfaces.tracklist = new TracklistInterface(this);\n this.#addEventedPropertiesList(this.interfaces.tracklist, ['CanEditTracks']);\n\n Object.defineProperty(this, 'tracks', {\n get: function() {\n return this._tracks;\n },\n set: function(value) {\n this._tracks = value;\n this.interfaces.tracklist.TrackListReplaced(value);\n },\n enumerable: true,\n configurable: true\n });\n }\n\n #addPlaylistsInterface(bus) {\n this.interfaces.playlists = new PlaylistsInterface(this);\n this.#addEventedPropertiesList(this.interfaces.playlists,\n ['PlaylistCount', 'ActivePlaylist']);\n }\n\n /**\n * Get a valid object path with the `subpath` as the basename which is suitable\n * for use as an id.\n *\n * @name Player#objectPath\n * @function\n * @param {String} subpath - The basename of this path\n * @returns {String} - A valid object path that can be used as an id.\n */\n objectPath(subpath) {\n let path = `/org/node/mediaplayer/${this.name}`;\n if (subpath) {\n path += `/${subpath}`;\n }\n return path;\n }\n\n #addEventedProperty(iface, name) {\n let localName = lcfirst(name);\n\n Object.defineProperty(this, localName, {\n get: function() {\n let value = iface[name];\n if (name === 'ActivePlaylist') {\n return types.playlistToPlain(value);\n } else if (name === 'Metadata') {\n return types.metadataToPlain(value);\n }\n return value;\n },\n set: function(value) {\n iface.setProperty(name, value);\n },\n enumerable: true,\n configurable: true\n });\n }\n\n #addEventedPropertiesList(iface, props) {\n for (let i = 0; i < props.length; i++) {\n this.#addEventedProperty(iface, props[i]);\n }\n }\n\n /**\n * Gets the position of this player. This method is intended to be overridden\n * by the user to return the position of the player in microseconds.\n *\n * @name Player#getPosition\n * @function\n * @returns {Number} - The current position of the player in microseconds. (Integer)\n */\n getPosition() {\n return 0;\n }\n\n /**\n * Emits the `Seeked` DBus signal to listening clients with the given position.\n *\n * @name Player#seeked\n * @function\n * @param {Number} position - The position in microseconds. (Integer)\n */\n seeked(position) {\n let seekTo = Math.floor(position || 0);\n if (isNaN(seekTo)) {\n throw new Error(`seeked expected a number (got ${position})`);\n }\n this.interfaces.player.Seeked(seekTo);\n }\n\n getTrackIndex(trackId) {\n for (let i = 0; i < this.tracks.length; i++) {\n let track = this.tracks[i];\n\n if (track['mpris:trackid'] === trackId) {\n return i;\n }\n }\n\n return -1;\n }\n\n getTrack(trackId) {\n return this.tracks[this.getTrackIndex(trackId)];\n }\n\n addTrack(track) {\n this.tracks.push(track);\n this.interfaces.tracklist.setTracks(this.tracks);\n\n let afterTrack = '/org/mpris/MediaPlayer2/TrackList/NoTrack';\n if (this.tracks.length > 2) {\n afterTrack = this.tracks[this.tracks.length - 2]['mpris:trackid'];\n }\n this.interfaces.tracklist.TrackAdded(afterTrack);\n }\n\n removeTrack(trackId) {\n let i = this.getTrackIndex(trackId);\n this.tracks.splice(i, 1);\n this.interfaces.tracklist.setTracks(this.tracks);\n\n this.interfaces.tracklist.TrackRemoved(trackId);\n }\n\n /**\n * Get the index of a playlist entry in the `playlists` list property of the\n * player from the given id.\n *\n * @name Player#getPlaylistIndex\n * @function\n * @param {String} playlistId - The id for the playlist entry.\n */\n getPlaylistIndex(playlistId) {\n for (let i = 0; i < this.playlists.length; i++) {\n let playlist = this.playlists[i];\n\n if (playlist.Id === playlistId) {\n return i;\n }\n }\n\n return -1;\n }\n\n /**\n * Set the list of playlists advertised to listeners on the bus. Each playlist\n * must have string members `Id`, `Name`, and `Icon`.\n *\n * @name Player#setPlaylists\n * @function\n * @param {Array} playlists - A list of playlists.\n */\n setPlaylists(playlists) {\n this.playlists = playlists;\n this.playlistCount = playlists.length;\n\n this.playlists.forEach((playlist) => {\n if (playlist) {\n this.interfaces.playlists.PlaylistChanged(playlist);\n }\n });\n }\n\n /**\n * Set the playlist identified by `playlistId` to be the currently active\n * playlist.\n *\n * @name Player#setActivePlaylist\n * @function\n * @param {String} playlistId - The id of the playlist to activate.\n */\n setActivePlaylist(playlistId) {\n this.interfaces.playlists.setActivePlaylistId(playlistId);\n }\n\n /**\n * Enumerated value for the `playbackStatus` property of the player to indicate\n * a track is currently playing.\n *\n * @name Player#PLAYBACK_STATUS_PLAYING\n * @static\n * @constant\n */\n static PLAYBACK_STATUS_PLAYING = constants.PLAYBACK_STATUS_PLAYING;\n /**\n * Enumerated value for the `playbackStatus` property of the player to indicate\n * a track is currently paused.\n *\n * @name Player#PLAYBACK_STATUS_PAUSED\n * @static\n * @constant\n */\n static PLAYBACK_STATUS_PAUSED = constants.PLAYBACK_STATUS_PAUSED;\n\n /**\n * Enumerated value for the `playbackStatus` property of the player to indicate\n * there is no track currently playing.\n *\n * @name Player#PLAYBACK_STATUS_STOPPED\n * @static\n * @constant\n */\n static PLAYBACK_STATUS_STOPPED = constants.PLAYBACK_STATUS_STOPPED;\n\n /**\n * Enumerated value for the `loopStatus` property of the player to indicate\n * playback will stop when there are no more tracks to play.\n *\n * @name Player#LOOP_STATUS_NONE\n * @static\n * @constant\n */\n static LOOP_STATUS_NONE = constants.LOOP_STATUS_NONE;\n\n /**\n * Enumerated value for the `loopStatus` property of the player to indicate the\n * current track will start again from the beginning once it has finished\n * playing.\n *\n * @name Player#LOOP_STATUS_TRACK\n * @static\n * @constant\n */\n static LOOP_STATUS_TRACK = constants.LOOP_STATUS_TRACK;\n\n /**\n * Enumerated value for the `loopStatus` property of the player to indicate the\n * playback loops through a list of tracks.\n *\n * @name Player#LOOP_STATUS_PLAYLIST\n * @static\n * @constant\n */\n static LOOP_STATUS_PLAYLIST = constants.LOOP_STATUS_PLAYLIST;\n}\n\nmodule.exports = Player;"],"mappings":";;;;;;;;AAAAA,OAAO,CAAC,oBAAoB,CAAC,CAACC,OAAO,CAAC,CAAC;AAEvC,MAAM;EAAEC;AAAa,CAAC,GAAGF,OAAO,CAAC,QAAQ,CAAC;AAE1C,MAAMG,IAAI,GAAGH,OAAO,CAAC,uBAAuB,CAAC;AAC7C,MAAMI,eAAe,GAAGJ,OAAO,CAAC,qBAAqB,CAAC;AACtD,MAAMK,aAAa,GAAGL,OAAO,CAAC,mBAAmB,CAAC;AAClD,MAAMM,kBAAkB,GAAGN,OAAO,CAAC,wBAAwB,CAAC;AAC5D,MAAMO,kBAAkB,GAAGP,OAAO,CAAC,wBAAwB,CAAC;AAC5D,MAAMQ,KAAK,GAAGR,OAAO,CAAC,oBAAoB,CAAC;AAC3C,MAAMS,SAAS,GAAGT,OAAO,CAAC,aAAa,CAAC;AAExC,MAAMU,UAAU,GAAG,yBAAyB;AAE5C,SAASC,OAAOA,CAACC,GAAG,EAAE;EACpB,OAAOA,GAAG,CAAC,CAAC,CAAC,CAACC,WAAW,CAAC,CAAC,GAAGD,GAAG,CAACE,SAAS,CAAC,CAAC,CAAC;AAChD;AAAC,IAAAC,aAAA,oBAAAC,OAAA;AAED,MAAMC,MAAM,SAASf,YAAY,CAAC;EAChC;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACEgB,WAAWA,CAACC,OAAO,EAAE;IACnB,KAAK,CAAC,CAAC;IAACC,2BAAA,OAAAL,aAAA;IAER,IAAI,CAACM,IAAI,GAAGF,OAAO,CAACE,IAAI;IACxB,IAAI,CAACC,mBAAmB,GAAGH,OAAO,CAACG,mBAAmB,IAAI,CAAC,QAAQ,CAAC;IACpE,IAAI,CAACC,OAAO,GAAG,EAAE;IACjB,IAAI,CAACC,IAAI,CAACL,OAAO,CAAC;EACpB;EAEAK,IAAIA,CAACC,IAAI,EAAE;IACT,IAAI,CAACC,WAAW,GAAG,0BAA0B,IAAI,CAACL,IAAI,EAAE;IACxDlB,IAAI,CAACwB,UAAU,CAACC,kBAAkB,CAAC,IAAI,CAACF,WAAW,CAAC;IAEpD,IAAI,CAACG,IAAI,GAAG1B,IAAI,CAAC2B,UAAU,CAAC,CAAC;IAE7B,IAAI,CAACD,IAAI,CAACE,EAAE,CAAC,OAAO,EAAGC,GAAG,IAAK;MAC7B,IAAI,CAACC,IA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ACA;AACA;AAPEH,eAAA,CA1aIjG,MAAM,sBAkbgBR,SAAS,CAAC6G,gBAAgB;AAEpD;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAREJ,eAAA,CApbIjG,MAAM,uBA6biBR,SAAS,CAAC8G,iBAAiB;AAEtD;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AAPEL,eAAA,CA/bIjG,MAAM,0BAucoBR,SAAS,CAAC+G,oBAAoB;AAG9DC,MAAM,CAACC,OAAO,GAAGzG,MAAM","ignoreList":[]}
|
|
@@ -1,20 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
const dbus = require('dbus-next');
|
|
4
|
-
const Variant = dbus.Variant;
|
|
3
|
+
const dbus = require('@jellybrick/dbus-next');
|
|
5
4
|
const types = require('./types');
|
|
6
5
|
const deepEqual = require('deep-equal');
|
|
7
6
|
const constants = require('../constants');
|
|
8
7
|
const logging = require('../logging');
|
|
9
|
-
|
|
10
|
-
Interface
|
|
11
|
-
property,
|
|
12
|
-
method,
|
|
13
|
-
signal,
|
|
14
|
-
DBusError,
|
|
15
|
-
ACCESS_READ,
|
|
16
|
-
ACCESS_WRITE,
|
|
17
|
-
ACCESS_READWRITE
|
|
8
|
+
const {
|
|
9
|
+
Interface
|
|
18
10
|
} = dbus.interface;
|
|
19
11
|
class MprisInterface extends Interface {
|
|
20
12
|
constructor(name, player) {
|
|
@@ -23,7 +15,7 @@ class MprisInterface extends Interface {
|
|
|
23
15
|
}
|
|
24
16
|
_setPropertyInternal(property, valueDbus) {
|
|
25
17
|
// nothing is currently settable internally that needs conversion to plain
|
|
26
|
-
this.player.emit(property[0].toLowerCase() + property.
|
|
18
|
+
this.player.emit(property[0].toLowerCase() + property.substring(1), valueDbus);
|
|
27
19
|
}
|
|
28
20
|
setProperty(property, valuePlain) {
|
|
29
21
|
// convert the plain value to a dbus value (default to the plain value)
|
|
@@ -41,9 +33,9 @@ class MprisInterface extends Interface {
|
|
|
41
33
|
}
|
|
42
34
|
if (!deepEqual(this[`_${property}`], valueDbus)) {
|
|
43
35
|
this[`_${property}`] = valueDbus;
|
|
44
|
-
if (property
|
|
36
|
+
if (property === 'LoopStatus' && !constants.isLoopStatusValid(valuePlain)) {
|
|
45
37
|
logging.warn(`setting player loop status to an invalid value: ${valuePlain}`);
|
|
46
|
-
} else if (property
|
|
38
|
+
} else if (property === 'PlaybackStatus' && !constants.isPlaybackStatusValid(valuePlain)) {
|
|
47
39
|
logging.warn(`setting player playback status to an invalid value: ${valuePlain}`);
|
|
48
40
|
} else {
|
|
49
41
|
let changedProperties = {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mpris-interface.js","names":["dbus","require","
|
|
1
|
+
{"version":3,"file":"mpris-interface.js","names":["dbus","require","types","deepEqual","constants","logging","Interface","interface","MprisInterface","constructor","name","player","_setPropertyInternal","property","valueDbus","emit","toLowerCase","substring","setProperty","valuePlain","metadataToDbus","playlistToDbus","emptyPlaylist","filter","t","map","isLoopStatusValid","warn","isPlaybackStatusValid","changedProperties","emitPropertiesChanged","module","exports"],"sourceRoot":"../../src/","sources":["interfaces/mpris-interface.js"],"sourcesContent":["const dbus = require('@jellybrick/dbus-next');\nconst types = require('./types');\nconst deepEqual = require('deep-equal');\nconst constants = require('../constants');\nconst logging = require('../logging');\n\nconst { Interface } = dbus.interface;\n\nclass MprisInterface extends Interface {\n constructor(name, player) {\n super(name);\n this.player = player;\n }\n\n _setPropertyInternal(property, valueDbus) {\n // nothing is currently settable internally that needs conversion to plain\n this.player.emit(property[0].toLowerCase() + property.substring(1), valueDbus);\n }\n\n setProperty(property, valuePlain) {\n // convert the plain value to a dbus value (default to the plain value)\n let valueDbus = valuePlain;\n\n if (property === 'Metadata') {\n valueDbus = types.metadataToDbus(valuePlain);\n } else if (property === 'ActivePlaylist') {\n if (valuePlain) {\n valueDbus = [ true, types.playlistToDbus(valuePlain) ];\n } else {\n valueDbus = [ false, types.emptyPlaylist ];\n }\n } else if (property === 'Tracks') {\n valueDbus =\n valuePlain.filter((t) => t['mpris:trackid']).map((t) => t['mpris:trackid']);\n }\n\n if (!deepEqual(this[`_${property}`], valueDbus)) {\n this[`_${property}`] = valueDbus;\n\n if (property === 'LoopStatus' && !constants.isLoopStatusValid(valuePlain)) {\n logging.warn(`setting player loop status to an invalid value: ${valuePlain}`);\n } else if (property === 'PlaybackStatus' && !constants.isPlaybackStatusValid(valuePlain)) {\n logging.warn(`setting player playback status to an invalid value: ${valuePlain}`);\n } else {\n let changedProperties = {};\n changedProperties[property] = valueDbus;\n Interface.emitPropertiesChanged(this, changedProperties);\n }\n }\n }\n}\n\nmodule.exports = MprisInterface;\n"],"mappings":";;AAAA,MAAMA,IAAI,GAAGC,OAAO,CAAC,uBAAuB,CAAC;AAC7C,MAAMC,KAAK,GAAGD,OAAO,CAAC,SAAS,CAAC;AAChC,MAAME,SAAS,GAAGF,OAAO,CAAC,YAAY,CAAC;AACvC,MAAMG,SAAS,GAAGH,OAAO,CAAC,cAAc,CAAC;AACzC,MAAMI,OAAO,GAAGJ,OAAO,CAAC,YAAY,CAAC;AAErC,MAAM;EAAEK;AAAU,CAAC,GAAGN,IAAI,CAACO,SAAS;AAEpC,MAAMC,cAAc,SAASF,SAAS,CAAC;EACrCG,WAAWA,CAACC,IAAI,EAAEC,MAAM,EAAE;IACxB,KAAK,CAACD,IAAI,CAAC;IACX,IAAI,CAACC,MAAM,GAAGA,MAAM;EACtB;EAEAC,oBAAoBA,CAACC,QAAQ,EAAEC,SAAS,EAAE;IACxC;IACA,IAAI,CAACH,MAAM,CAACI,IAAI,CAACF,QAAQ,CAAC,CAAC,CAAC,CAACG,WAAW,CAAC,CAAC,GAAGH,QAAQ,CAACI,SAAS,CAAC,CAAC,CAAC,EAAEH,SAAS,CAAC;EAChF;EAEAI,WAAWA,CAACL,QAAQ,EAAEM,UAAU,EAAE;IAChC;IACA,IAAIL,SAAS,GAAGK,UAAU;IAE1B,IAAIN,QAAQ,KAAK,UAAU,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