@amazon-devices/kepler-media-controls 1.0.17

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.
Files changed (36) hide show
  1. package/LICENSE +7 -0
  2. package/SystemBundles/ccb7cf3a42fbe7b00b72ad1b7cc41cb45c8c491032e9dfe359f1830234d5d040.bundle +2277 -0
  3. package/SystemBundles/ccb7cf3a42fbe7b00b72ad1b7cc41cb45c8c491032e9dfe359f1830234d5d040.bundle.map +1 -0
  4. package/SystemModules/amzn__kepler-media-controls.modules.txt +10 -0
  5. package/SystemModules/amzn__kepler-media-controls.private.modules.txt +21 -0
  6. package/SystemModules/keplerscript-system-bundle-config.json +7 -0
  7. package/THIRD_PARTY_NOTICES.txt +12224 -0
  8. package/dist/MediaControlClientAsync.d.ts +226 -0
  9. package/dist/MediaControlClientAsync.js +355 -0
  10. package/dist/MediaControlComponentAsync.d.ts +8 -0
  11. package/dist/MediaControlComponentAsync.js +26 -0
  12. package/dist/MediaControlEndpointLocatorAsync.d.ts +19 -0
  13. package/dist/MediaControlEndpointLocatorAsync.js +70 -0
  14. package/dist/MediaControlServer.d.ts +37 -0
  15. package/dist/MediaControlServer.js +218 -0
  16. package/dist/MediaControlServerComponentAsync.d.ts +7 -0
  17. package/dist/MediaControlServerComponentAsync.js +29 -0
  18. package/dist/index.d.ts +3 -0
  19. package/dist/index.js +25 -0
  20. package/dist/kepler/tm-manifest.json +1 -0
  21. package/dist/turbo-modules/KeplerMediaControlsClientTM.d.ts +50 -0
  22. package/dist/turbo-modules/KeplerMediaControlsClientTM.js +18 -0
  23. package/dist/turbo-modules/KeplerMediaControlsServerTM.d.ts +17 -0
  24. package/dist/turbo-modules/KeplerMediaControlsServerTM.js +18 -0
  25. package/dist/turbo-modules/__mocks__/KeplerMediaControlsClientTM.d.ts +6 -0
  26. package/dist/turbo-modules/__mocks__/KeplerMediaControlsClientTM.js +7 -0
  27. package/dist/turbo-modules/__mocks__/KeplerMediaControlsServerTM.d.ts +7 -0
  28. package/dist/turbo-modules/__mocks__/KeplerMediaControlsServerTM.js +8 -0
  29. package/dist/turbo-modules/types/KeplerMediaControlsTypes.d.ts +859 -0
  30. package/dist/turbo-modules/types/KeplerMediaControlsTypes.js +152 -0
  31. package/dist/turbo-modules/types/index.d.ts +2 -0
  32. package/dist/turbo-modules/types/index.js +20 -0
  33. package/kepler-compatibility.json +13 -0
  34. package/kepler-transformed-package-info.json +3 -0
  35. package/package.json +1 -0
  36. package/react-native.config.js +22 -0
@@ -0,0 +1,859 @@
1
+ import { IComponentInstance } from '@amazon-devices/react-native-kepler';
2
+ import { MediaId } from '@amazon-devices/kepler-media-types';
3
+ /**
4
+ * Specifies the playback status.
5
+ */
6
+ export declare enum PlaybackStatus {
7
+ PLAYING = "PLAYING",
8
+ PAUSED = "PAUSED",
9
+ NOT_PLAYING = "NOT_PLAYING",
10
+ BUFFERING = "BUFFERING"
11
+ }
12
+ /**
13
+ * Represents the actions that you can invoke using the media control client.
14
+ */
15
+ export declare class Action {
16
+ name: string;
17
+ constructor(name: string);
18
+ static readonly PLAY: Action;
19
+ static readonly PAUSE: Action;
20
+ static readonly TOGGLE_PLAY_PAUSE: Action;
21
+ static readonly STOP: Action;
22
+ static readonly START_OVER: Action;
23
+ static readonly FAST_FORWARD: Action;
24
+ static readonly REWIND: Action;
25
+ static readonly SET_PLAYBACK_SPEED: Action;
26
+ static readonly SKIP_FORWARD: Action;
27
+ static readonly SKIP_BACKWARD: Action;
28
+ static readonly SEEK: Action;
29
+ static readonly SET_AUDIO_VOLUME: Action;
30
+ static readonly SET_AUDIO_TRACK: Action;
31
+ static readonly ENABLE_TEXT_TRACK: Action;
32
+ static readonly DISBLE_TEXT_TRACK: Action;
33
+ static readonly NEXT: Action;
34
+ static readonly PREVIOUS: Action;
35
+ static readonly ENABLE_SHUFFLE: Action;
36
+ static readonly SET_REPEAT_MODE: Action;
37
+ static readonly SET_RATING: Action;
38
+ static readonly GET_META_DATA: Action;
39
+ }
40
+ /**
41
+ * Specifies the repeat mode for the media player.
42
+ */
43
+ export declare enum RepeatMode {
44
+ OFF = 0,
45
+ REPEAT_TRACK = 1,
46
+ REPEAT_PLAYLIST = 2
47
+ }
48
+ /**
49
+ * Specifies the radio band for the media player.
50
+ */
51
+ export declare enum RadioBand {
52
+ NONE = "NONE",
53
+ UNKNOWN = "UNKNOWN",
54
+ AM = "AM",
55
+ FM = "FM",
56
+ DAB = "DAB"
57
+ }
58
+ /**
59
+ * Specifies the source of the media command.
60
+ */
61
+ export declare enum CommandSource {
62
+ SYSTEM_DISPLAY_OFF = "SYSTEM_DISPLAY_OFF",
63
+ USER = "USER",
64
+ OTHER = "OTHER"
65
+ }
66
+ /**
67
+ * Error occurs when a request cannot be processed due to being in the
68
+ * wrong state to process it.
69
+ */
70
+ export declare class InvalidStateError extends Error {
71
+ constructor(message: string);
72
+ }
73
+ /**
74
+ * Error occurs when a request cannot be handled.
75
+ */
76
+ export declare class NotAllowedError extends Error {
77
+ constructor(message: string);
78
+ }
79
+ /**
80
+ * Error occurs when the requested playback speed is not supported.
81
+ */
82
+ export declare class SpeedOutOfRangeError extends Error {
83
+ constructor(message: string);
84
+ }
85
+ /**
86
+ * Error occurs when the requested seek position is out of the advertised range.
87
+ */
88
+ export declare class SeekOutOfRangeError extends Error {
89
+ constructor(message: string);
90
+ }
91
+ /**
92
+ * Error occurs when requested data is not available.
93
+ */
94
+ export declare class NotAvailableError extends Error {
95
+ constructor(message: string);
96
+ }
97
+ /**
98
+ * interface for TimeValue, used to represent a time value structure.
99
+ * @property seconds @type {number} A postive number representing seconds.
100
+ * @property nanoseconds @type {number} A positive number representing nanoseconds. Maximum value can be 999999999.
101
+ */
102
+ export interface ITimeValue {
103
+ seconds: number;
104
+ nanoseconds: number;
105
+ }
106
+ /**
107
+ * Represents the playback position of the track.
108
+ * @property updatedAtTime @type {ITimeValue} The time at which the playback position was recorded.
109
+ * @property position @type {ITimeValue} The recorded position of the media during playback.
110
+ */
111
+ export interface IPlaybackPosition {
112
+ updatedAtTime: ITimeValue;
113
+ position: ITimeValue;
114
+ }
115
+ /**
116
+ * Represents the playback state of the track.
117
+ * @property playbackStatus @type {PlaybackStatus} The status of the media track.
118
+ * @property playbackSpeed @type {number} The speed of the media track.
119
+ * @property position @type {IPlaybackPosition} The position of the media track.
120
+ */
121
+ export interface IPlaybackState {
122
+ playbackStatus: PlaybackStatus;
123
+ playbackSpeed: number;
124
+ position?: IPlaybackPosition;
125
+ }
126
+ /**
127
+ * interface representing the locale of the track.
128
+ * @property identifier @type {string} The locale of the track.
129
+ */
130
+ export interface ILocale {
131
+ identifier: string;
132
+ }
133
+ /**
134
+ * Represents a track information.
135
+ * @property id @type {string} The identifier for the track.
136
+ * @property language @type {string} The language of the track.
137
+ * @property displayName @type {string} The display name of the track.
138
+ */
139
+ export interface ITrack {
140
+ id: string;
141
+ language: ILocale;
142
+ displayName?: string;
143
+ }
144
+ /**
145
+ * Represents the capabilities of a media endpoint.
146
+ * @property actions @type {Action[]} An array of actions.
147
+ * @property speeds @type {number[]} An array of supported speeds.
148
+ * @property ratings @type {number[]} An array of ratings.
149
+ * @property forwardSkipSteps @type {ITimeValue[]} An array of forward skip steps.
150
+ * @property backwardSkipSteps @type {ITimeValue[]} An array of backward skip steps.
151
+ */
152
+ export interface ICapabilities {
153
+ actions: Action[];
154
+ speeds: number[];
155
+ ratings: number[];
156
+ forwardSkipSteps: ITimeValue[];
157
+ backwardSkipSteps: ITimeValue[];
158
+ }
159
+ /**
160
+ * Represents the state of a playlist.
161
+ * @property repeatMode @type {RepeatMode} the repeat mode of the playlist.
162
+ * @property shuffle @type {boolean} if the playlist should be shuffled.
163
+ */
164
+ export interface IPlaylistState {
165
+ repeatMode: RepeatMode;
166
+ shuffle: boolean;
167
+ }
168
+ /**
169
+ * Represents the artwork expected by objects.
170
+ * @property url @type {string} URL of the artwork.
171
+ * @property sizeTag @type {string} Optional. Size tag of artwork.
172
+ * @property id @type {string} Optional. ID of artwork.
173
+ * @property tag @type {string} Optional. Tag of artwork.
174
+ */
175
+ export interface IArtwork {
176
+ url: string;
177
+ sizeTag?: string;
178
+ id?: string;
179
+ tag?: string;
180
+ }
181
+ /**
182
+ * Represents information about a radio station.
183
+ * @property stationName @type {string} Optional. The Name of the radio station.
184
+ * @property stationCode @type {string} Optional. The code of the radio station.
185
+ * @property stationLogo @type {} An array of logos supported by the radio station.
186
+ * @property frequency @type {string} Optional. The frequency of the radio station.
187
+ * @property band @type {string} Optional. The broadcast band of the radio station.
188
+ * @property subChannels @type {string} Optional. An array of strings speicifying the sub channels of the radio station.
189
+ * @property serviceFollowing @type {RadioBand} The service following of the radio station.
190
+ * @property activeSubchannel @type {string} Optional. The active subchannel of the radio station.
191
+ * @property radioText @type {string} Optional. The radio text of the radio station.
192
+ * @property isMuted @type {boolean} Optional. If the radio station is muted.
193
+ * @property isDigital @type {boolean} Optional. If the radio station is digital.
194
+ * @property isStereo @type {boolean} Optional. If the radio station is stereo.
195
+ * @property isDigitalAudio @type {boolean} Optional. If the radio station is digital audio.
196
+ * @property isLiveAudio @type {boolean} Optional. If the radio station is live audio.
197
+ * @property isAcquiring @type {boolean} Optional. If the radio station is acquiring.
198
+ */
199
+ export interface IRadioStationInfo {
200
+ stationName?: string;
201
+ stationCode?: string;
202
+ stationLogo: IArtwork[];
203
+ frequency?: string;
204
+ band?: string;
205
+ subChannels: string[];
206
+ serviceFollowing: RadioBand;
207
+ activeSubchannel?: string;
208
+ radioText?: string;
209
+ isMuted: boolean;
210
+ isDigital: boolean;
211
+ isStereo: boolean;
212
+ isDigitalAudio: boolean;
213
+ isLiveAudio: boolean;
214
+ isAcquiring: boolean;
215
+ }
216
+ /**
217
+ * Represents information about the media provider.
218
+ * @property name @type {string} The name of media provider.
219
+ * @property logo @type {IArtwork} An array of logo supported by the media provider.
220
+ */
221
+ export interface IMediaProviderInfo {
222
+ name: string;
223
+ logo: IArtwork[];
224
+ }
225
+ /**
226
+ * Represents information about an artist.
227
+ * @property name @type {string} The name of the artist.
228
+ * @property id @type {string} The ID of the artist.
229
+ */
230
+ export interface IArtist {
231
+ name: string;
232
+ id: string;
233
+ }
234
+ /**
235
+ * Represents infomation about an audio book.
236
+ * @property chapterTitle @type {string} Optional. The title of a chapter.
237
+ * @property narrator @type {IArtist} Optional. An array that contains the narrators of the audio book.
238
+ */
239
+ export interface IAudioBookInfo {
240
+ chapterTitle?: string;
241
+ narrator: IArtist[];
242
+ }
243
+ /**
244
+ * Represent the playback source.
245
+ * @property source @type {string} The source of playback.
246
+ * @property id @type {string} Optional. The ID of the playback source.
247
+ */
248
+ export interface IPlaybackSource {
249
+ source: string;
250
+ id?: string;
251
+ }
252
+ /**
253
+ * interface expected by object returning metadata.
254
+ * @property mediaId @type {MediaId | string} The ID of the media.
255
+ * @property title @type {string} Optional. The title of the media.
256
+ * @property date @type {string} Optional. The date of the media.
257
+ * @property authors @type {IArtist[]} Optional. An array that contains the authors of the media.
258
+ * @property artists @type {IArtist[]} Optional. An array that contains the artists of the media.
259
+ * @property composers @type {IArtist[]} Optional. An array that contains the composers of the media.
260
+ * @property genre @type {string} Optional. The genre of the media.
261
+ * @property description @type {string} Optional. The description of the media
262
+ * @property album @type {string} Optional. The album that contains the media.
263
+ * @property artwork @type {IArtwork[]} An artwork of media.
264
+ * @property radioStationInfo @type {IRadioStationInfo} Optional. Information about the radio station that is playing the media.
265
+ * @property mediaProviderInfo @type {IMediaProviderInfo} Optional. Information about the media provider that is playing the media.
266
+ * @property audioBookInfo @type {IAudioBookInfo} Optional. Information about the audio book that is playing the media.
267
+ * @property playbackSource @type {IPlaybackSource} Optional. Information about the playback source.
268
+ * @property mediaType @type {string} Optional. The type of media.
269
+ */
270
+ export interface IMediaMetadata {
271
+ mediaId: MediaId | string;
272
+ title?: string;
273
+ date?: string;
274
+ authors?: IArtist[];
275
+ artists?: IArtist[];
276
+ composers?: IArtist[];
277
+ genre?: string;
278
+ description?: string;
279
+ album?: string;
280
+ artwork: IArtwork[];
281
+ radioStationInfo?: IRadioStationInfo;
282
+ mediaProviderInfo?: IMediaProviderInfo;
283
+ audioBookInfo?: IAudioBookInfo;
284
+ playbackSource?: IPlaybackSource;
285
+ mediaType?: string;
286
+ }
287
+ /**
288
+ * Optional context passed to a media command.
289
+ * @property source @type {CommandSource} The initiator of the command, e.g., remote control or display turned off.
290
+ */
291
+ export interface ICommandContext {
292
+ source: CommandSource;
293
+ }
294
+ /**
295
+ * Repesents a generic error that might be thrown.
296
+ * @property type @type {string} The type of error.
297
+ * @property message @type {string} The message describing the error.
298
+ */
299
+ export interface KeplerMediaControlsError {
300
+ type: string;
301
+ message: string;
302
+ }
303
+ /**
304
+ * Represents a subscription that can be used to subsribe to various things.
305
+ * like media endpoint listener, media state changes etc.
306
+ */
307
+ export interface ISubscription {
308
+ /**
309
+ * Removes the subscription.
310
+ */
311
+ unsubscribe: () => void;
312
+ }
313
+ /**
314
+ * When implemented, handles media control state changes.
315
+ */
316
+ export interface IMediaControlListener {
317
+ /**
318
+ * Invoked when a media control endpoint session changes state.
319
+ * @param updatedStates @type {MediaSessionState[]} array of updated states.
320
+ */
321
+ onStateChanged: (updatedStates: MediaSessionState[]) => void;
322
+ }
323
+ /**
324
+ * Represents a media session ID.
325
+ * @property id @type {number} The ID of the session.
326
+ */
327
+ export interface IMediaSessionId {
328
+ id: number;
329
+ }
330
+ /**
331
+ * Represents information about the media.
332
+ * @property id @type {MediaId} The ID of the media.
333
+ * @property hasVideo @type {boolean} When set to `true` the media has a video component; otherwise `false`.
334
+ * @property availableAudioTracks @type {ITrack[]} An array of the available audio tracks.
335
+ * @property availableTextTracks @type {ITrack[]} An array of the available text tracks.
336
+ * @property duration @type {ITimeValue} The duration of the media.
337
+ * @property startTime @type {ITimeValue} The start time of the media.
338
+ * @property seekRangeStart @type {ITimeValue} The start of the seek range.
339
+ * @property seekRangeEnd @type {ITimeValue} The end of the seek range.
340
+ * @property activeAudioTrack @type {ITrack} The active audio track.
341
+ * @property activeTextTrack @type {ITrack} the active text track.
342
+ * @property currentRating @type {number} The current rating.
343
+ */
344
+ export interface IMediaInfo {
345
+ id: MediaId;
346
+ hasVideo: boolean;
347
+ availableAudioTracks: ITrack[];
348
+ availableTextTracks: ITrack[];
349
+ duration?: ITimeValue;
350
+ startTime?: ITimeValue;
351
+ seekRangeStart?: ITimeValue;
352
+ seekRangeEnd?: ITimeValue;
353
+ activeAudioTrack?: ITrack;
354
+ activeTextTrack?: ITrack;
355
+ currentRating?: number;
356
+ }
357
+ /**
358
+ * Represents a control.
359
+ * @property name @type {string} The name of the control.
360
+ * @property state @type {string} The state of the control.
361
+ */
362
+ export interface IControl {
363
+ name: string;
364
+ state: string;
365
+ }
366
+ /**
367
+ * Represents the media session state.
368
+ * @property id @type {IMediaSessionId} The ID of the session.
369
+ * @property playbackState @type {IPlaybackState} The playback state.
370
+ * @property mediaInfo @type {IMediaInfo} The information about the media.
371
+ * @property capabilities @type {ICapabilities} The capabilities supported by the media.
372
+ * @property playlistState @type {IPlaylistState} The state of the playlist.
373
+ * @property controls @type {IControl[]} An array of controls for supported by the media player.
374
+ */
375
+ export interface MediaSessionState {
376
+ id: IMediaSessionId;
377
+ playbackState: IPlaybackState;
378
+ mediaInfo?: IMediaInfo;
379
+ capabilities: ICapabilities;
380
+ playlistState?: IPlaylistState;
381
+ controls: IControl[];
382
+ }
383
+ /**
384
+ * Represeents the package ID of an app.
385
+ * @property id @type {string} The ID of the package.
386
+ */
387
+ export interface IPackageId {
388
+ id: string;
389
+ }
390
+ /**
391
+ * When implemented, handles media control callbacks.
392
+ */
393
+ export interface IMediaControlHandlerAsync {
394
+ /**
395
+ * Handles a play request initiated through a media control.
396
+ * @param sessionId @type {IMediaSessionId} Optional. The session ID to target with the request.
397
+ * @returns @type {Promise} of @type {void} A Promise that resolves when the play request is successfully handled,
398
+ * or rejects with an error if the request fails.
399
+ */
400
+ handlePlay: (sessionId?: IMediaSessionId) => Promise<void>;
401
+ /**
402
+ * Handles a pause request initiated through a media control.
403
+ * @param sessionId @type {IMediaSessionId} Optional. The session ID to target with the request.
404
+ * @param context @type {ICommandContext} Optional. Additional command context.
405
+ * @returns @type {Promise} of @type {void} A Promise that resolves when the pause request is successfully handled,
406
+ * or rejects with an error if the request fails.
407
+ */
408
+ handlePause: (sessionId?: IMediaSessionId, context?: ICommandContext) => Promise<void>;
409
+ /**
410
+ * Handles a toggle play pause request initiated through a media control.
411
+ * @param sessionId @type {IMediaSessionId} Optional. The session ID to target with the request.
412
+ * @returns @type {Promise} of @type {void} A Promise that resolves when the toggle play pause request is successfully handled,
413
+ * or rejects with an error if the request fails.
414
+ */
415
+ handleTogglePlayPause: (sessionId?: IMediaSessionId) => Promise<void>;
416
+ /**
417
+ * Handles a stop request initiated through a media control.
418
+ * @param sessionId @type {IMediaSessionId} Optional. The session ID to target with the request.
419
+ * @returns @type {Promise} of @type {void} A Promise that resolves when the stop request is successfully handled,
420
+ * or rejects with an error if the request fails.
421
+ */
422
+ handleStop: (sessionId?: IMediaSessionId) => Promise<void>;
423
+ /**
424
+ * Handles a start over request initiated through a media control.
425
+ * @param sessionId @type {IMediaSessionId} Optional. The session ID to target with the request.
426
+ * @returns @type {Promise} of @type {void} A Promise that resolves when the start over request is successfully handled,
427
+ * or rejects with an error if the request fails.
428
+ */
429
+ handleStartOver: (sessionId?: IMediaSessionId) => Promise<void>;
430
+ /**
431
+ * Handles a fast forward request initiated through a media control.
432
+ * @param sessionId @type {IMediaSessionId} Optional. The session ID to target with the request.
433
+ * @returns @type {Promise} of @type {void} A Promise that resolves when the fast forward request is successfully handled,
434
+ * or rejects with an error if the request fails.
435
+ */
436
+ handleFastForward: (sessionId?: IMediaSessionId) => Promise<void>;
437
+ /**
438
+ * Handles a rewind request initiated through a media control.
439
+ * @param sessionId @type {IMediaSessionId} Optional. The session ID to target with the request.
440
+ * @returns @type {Promise} of @type {void} A Promise that resolves when the rewind request is successfully handled,
441
+ * or rejects with an error if the request fails.
442
+ */
443
+ handleRewind: (sessionId?: IMediaSessionId) => Promise<void>;
444
+ /**
445
+ * Handles a set playback speed request initiated through a media control.
446
+ * @param speed @type {number} speed to set.
447
+ * @param sessionId @type {IMediaSessionId} Optional. The session ID to target with the request.
448
+ * @returns @type {Promise} of @type {void} A Promise that resolves when the set playback speed request is successfully handled,
449
+ * or rejects with an error if the request fails.
450
+ */
451
+ handleSetPlaybackSpeed: (speed: number, sessionId?: IMediaSessionId) => Promise<void>;
452
+ /**
453
+ * Handles a skip forward request initiated through a media control.
454
+ * @param delta @type {ITimeValue} delta to skip forward.
455
+ * @param sessionId @type {IMediaSessionId} Optional. The session ID to target with the request.
456
+ * @returns @type {Promise} of @type {void} A Promise that resolves when the skip forward request is successfully handled,
457
+ * or rejects with an error if the request fails.
458
+ */
459
+ handleSkipForward: (delta: ITimeValue, sessionId?: IMediaSessionId) => Promise<void>;
460
+ /**
461
+ * Handles a skip backward request initiated through a media control.
462
+ * @param delta @type {ITimeValue} delta to skip backward.
463
+ * @param sessionId @type {IMediaSessionId} Optional. The session ID to target with the request.
464
+ * @returns @type {Promise} of @type {void} A Promise that resolves when the skip backward request is successfully handled,
465
+ * or rejects with an error if the request fails.
466
+ */
467
+ handleSkipBackward: (delta: ITimeValue, sessionId?: IMediaSessionId) => Promise<void>;
468
+ /**
469
+ * Handles a seek request initiated through a media control.
470
+ * @param position @type {ITimeValue} position to seek to.
471
+ * @param sessionId @type {IMediaSessionId} Optional. The session ID to target with the request.
472
+ * @returns @type {Promise} of @type {void} A Promise that resolves when the seek request is successfully handled,
473
+ * or rejects with an error if the request fails.
474
+ */
475
+ handleSeek: (position: ITimeValue, sessionId?: IMediaSessionId) => Promise<void>;
476
+ /**
477
+ * Handles a set audio volume request initiated through a media control.
478
+ * @param volume @type {number} volume to set.
479
+ * @param sessionId @type {IMediaSessionId} Optional. The session ID to target with the request.
480
+ * @returns @type {Promise} of @type {void} A Promise that resolves when the set audio volume request is successfully handled,
481
+ * or rejects with an error if the request fails.
482
+ */
483
+ handleSetAudioVolume: (volume: number, sessionId?: IMediaSessionId) => Promise<void>;
484
+ /**
485
+ * Handles a set audio track request initiated through a media control.
486
+ * @param @type {ITrack} audioTrack track to set.
487
+ * @param sessionId @type {IMediaSessionId} Optional. The session ID to target with the request.
488
+ * @returns @type {Promise} of @type {void} A Promise that resolves when the set audio track request is successfully handled,
489
+ * or rejects with an error if the request fails.
490
+ */
491
+ handleSetAudioTrack: (audioTrack: ITrack, sessionId?: IMediaSessionId) => Promise<void>;
492
+ /**
493
+ * Handles an enable text track request initiated through a media control.
494
+ * @param @type {ITrack} textTrack track to enable.
495
+ * @param sessionId @type {IMediaSessionId} Optional. The session ID to target with the request.
496
+ * @returns @type {Promise} of @type {void} A Promise that resolves when the enable text track request is successfully handled,
497
+ * or rejects with an error if the request fails.
498
+ */
499
+ handleEnableTextTrack: (textTrack: ITrack, sessionId?: IMediaSessionId) => Promise<void>;
500
+ /**
501
+ * Handles a disable text track request initiated through a media control.
502
+ * @param sessionId @type {IMediaSessionId} Optional. The session ID to target with the request.
503
+ * @returns @type {Promise} of @type {void} A Promise that resolves when the disable text track request is successfully handled,
504
+ * or rejects with an error if the request fails.
505
+ */
506
+ handleDisableTextTrack: (sessionId?: IMediaSessionId) => Promise<void>;
507
+ /**
508
+ * Handles a next request initiated through a media control.
509
+ * @param sessionId @type {IMediaSessionId} Optional. The session ID to target with the request.
510
+ * @returns @type {Promise} of @type {void} A Promise that resolves when the next request is successfully handled,
511
+ * or rejects with an error if the request fails.
512
+ */
513
+ handleNext: (sessionId?: IMediaSessionId) => Promise<void>;
514
+ /**
515
+ * Handles a previous request initiated through a media control.
516
+ * @param sessionId @type {IMediaSessionId} Optional. The session ID to target with the request.
517
+ * @returns @type {Promise} of @type {void} A Promise that resolves when the previous request is successfully handled,
518
+ * or rejects with an error if the request fails.
519
+ */
520
+ handlePrevious: (sessionId?: IMediaSessionId) => Promise<void>;
521
+ /**
522
+ * Handles an enable shuffle request initiated through a media control.
523
+ * @param enable @type {boolean} enable shuffle.
524
+ * @param sessionId @type {IMediaSessionId} Optional. The session ID to target with the request.
525
+ * @returns @type {Promise} of @type {void} A Promise that resolves when the enable shuffle request is successfully handled,
526
+ * or rejects with an error if the request fails.
527
+ */
528
+ handleEnableShuffle: (enable: boolean, sessionId?: IMediaSessionId) => Promise<void>;
529
+ /**
530
+ * Handles a set repeat mode request initiated through a media control.
531
+ * @param mode @type {RepeatMode} repeat mode.
532
+ * @param sessionId @type {IMediaSessionId} Optional. The session ID to target with the request.
533
+ * @returns @type {Promise} of @type {void} A Promise that resolves when the pause set repeat mode is successfully handled,
534
+ * or rejects with an error if the request fails.
535
+ */
536
+ handleSetRepeatMode: (mode: RepeatMode, sessionId?: IMediaSessionId) => Promise<void>;
537
+ /**
538
+ * Handles a set rating request.
539
+ * @param id @type {MediaId} The ID of the media.
540
+ * @param rating @type {number} The value to set for the rating.
541
+ * @param sessionId @type {IMediaSessionId} Optional. The session ID to target with the request.
542
+ * @returns @type {Promise} of @type {void} A Promise that resolves when the set rating request is successfully handled,
543
+ * or rejects with an error if the request fails.
544
+ */
545
+ handleSetRating: (id: MediaId, rating: number, sessionId?: IMediaSessionId) => Promise<void>;
546
+ /**
547
+ * Handles a request for the metadata of the specified media item.
548
+ * @param id @type {MediaId} The ID of the media.
549
+ * @returns @type {Promise} of @type {void} A Promise that resolves when the request is successfully handled,
550
+ * or rejects with an error if the request fails.
551
+ */
552
+ handleGetMetadataInfo: (id: MediaId) => Promise<IMediaMetadata>;
553
+ /**
554
+ * Handles a request for a custom action.
555
+ * @param action @type {Action} The action to perform.
556
+ * @param sessionId @type {IMediaSessionId} Optional. The session ID to target with the request.
557
+ * @returns @type {Promise} of @type {void} A Promise that resolves when the request is successfully handled,
558
+ * or rejects with an error if the request fails.
559
+ */
560
+ handleCustomAction: (action: Action, sessionId?: IMediaSessionId) => Promise<void>;
561
+ /**
562
+ * Handles a request for the session state.
563
+ * @param sessionId @type {IMediaSessionId} Optional. The session ID of the session whose state is to be fetched.
564
+ * If not provided, treat as a request for data on all sessions.
565
+ * @returns @type {Promise} of @type {void} A Promise that resolves when the request is successfully handled,
566
+ * or rejects with an error if the request fails.
567
+ */
568
+ handleGetSessionState: (sessionId?: IMediaSessionId) => Promise<MediaSessionState[]>;
569
+ }
570
+ /**
571
+ * interface for media control clients
572
+ */
573
+ export interface IMediaControlClientAsync {
574
+ /**
575
+ * Sends a play request on the media control endpoint.
576
+ * @param sessionId @type {IMediaSessionId} Optional. The session ID to target with
577
+ * the request. If not provided, the session to target is decided by the endpoint.
578
+ * @returns @type {Promise} of @type {void} A Promise that resolves when the request is successfully handled,
579
+ * or rejects with an error if the request fails.
580
+ */
581
+ play: (sessionId?: IMediaSessionId) => Promise<void>;
582
+ /**
583
+ * Sends a pause requst on the media control endpoint.
584
+ * @param sessionId @type {IMediaSessionId} Optional. The session ID to target with
585
+ * the request. If not provided, the session to target is decided by the endpoint.
586
+ * @returns @type {Promise} of @type {void} A Promise that resolves when the request is successfully handled,
587
+ * or rejects with an error if the request fails.
588
+ */
589
+ pause: (sessionId?: IMediaSessionId) => Promise<void>;
590
+ /**
591
+ * Sends a togglePlayPause request on the media control endpoint.
592
+ * @param sessionId @type {IMediaSessionId} Optional. The session ID to target with
593
+ * the request. If not provided, the session to target is decided by the endpoint.
594
+ * @returns @type {Promise} of @type {void} A Promise that resolves when the request is successfully handled,
595
+ * or rejects with an error if the request fails.
596
+ */
597
+ togglePlayPause: (sessionId?: IMediaSessionId) => Promise<void>;
598
+ /**
599
+ * Sends a stop request on the media control endpoint.
600
+ * @param sessionId @type {IMediaSessionId} Optional. The session ID to target with
601
+ * the request. If not provided, the session to target is decided by the endpoint.
602
+ * @returns @type {Promise} of @type {void} A Promise that resolves when the request is successfully handled,
603
+ * or rejects with an error if the request fails.
604
+ */
605
+ stop: (sessionId?: IMediaSessionId) => Promise<void>;
606
+ /**
607
+ * Sends a startOver request on the media control endpoint.
608
+ * @param sessionId @type {IMediaSessionId} Optional. The session ID to target with
609
+ * the request. If not provided, the session to target is decided by the endpoint.
610
+ * @returns @type {Promise} of @type {void} A Promise that resolves when the request is successfully handled,
611
+ * or rejects with an error if the request fails.
612
+ */
613
+ startOver: (sessionId?: IMediaSessionId) => Promise<void>;
614
+ /**
615
+ * Sends a fastForward request on the media control endpoint.
616
+ * @param sessionId @type {IMediaSessionId} Optional. The session ID to target with
617
+ * the request. If not provided, the session to target is decided by the endpoint.
618
+ * @returns @type {Promise} of @type {void} A Promise that resolves when the request is successfully handled,
619
+ * or rejects with an error if the request fails.
620
+ */
621
+ fastForward: (sessionId?: IMediaSessionId) => Promise<void>;
622
+ /**
623
+ * Sends a rewind request on the media control endpoint.
624
+ * @param sessionId @type {IMediaSessionId} Optional. The session ID to target with
625
+ * the request. If not provided, the session to target is decided by the endpoint.
626
+ * @returns @type {Promise} of @type {void} A Promise that resolves when the request is successfully handled,
627
+ * or rejects with an error if the request fails.
628
+ */
629
+ rewind: (sessionId?: IMediaSessionId) => Promise<void>;
630
+ /**
631
+ * Sends a setPlaybackSpeed request on the media control endpoint.
632
+ * @param speed @type {number} speed to set.
633
+ * @param sessionId @type {IMediaSessionId} Optional. The session ID to target with
634
+ * the request. If not provided, the session to target is decided by the endpoint.
635
+ * @returns @type {Promise} of @type {void} A Promise that resolves when the request is successfully handled,
636
+ * or rejects with an error if the request fails.
637
+ */
638
+ setPlaybackSpeed: (speed: number, sessionId?: IMediaSessionId) => Promise<void>;
639
+ /**
640
+ * Sends a skipForward request on the media control endpoint.
641
+ * @param delta @type {ITimeValue} The time delta to skip forward.
642
+ * @param sessionId @type {IMediaSessionId} Optional. The session ID to target with
643
+ * the request. If not provided, the session to target is decided by the endpoint.
644
+ * @returns @type {Promise} of @type {void} A Promise that resolves when the request is successfully handled,
645
+ * or rejects with an error if the request fails.
646
+ */
647
+ skipForward: (delta: ITimeValue, sessionId?: IMediaSessionId) => Promise<void>;
648
+ /**
649
+ * Sends a skipBackward request on the media control endpoint.
650
+ * @param delta @type {ITimeValue} The time delta to skip backward.
651
+ * @param sessionId @type {IMediaSessionId} Optional. The session ID to target with
652
+ * the request. If not provided, the session to target is decided by the endpoint.
653
+ * @returns @type {Promise} of @type {void} A Promise that resolves when the request is successfully handled,
654
+ * or rejects with an error if the request fails.
655
+ */
656
+ skipBackward: (delta: ITimeValue, sessionId?: IMediaSessionId) => Promise<void>;
657
+ /**
658
+ * Sends a seek request on the media control endpoint.
659
+ * @param position @type {ITimeValue} The time position to seek to.
660
+ * @param sessionId @type {IMediaSessionId} Optional. The session ID to target with
661
+ * the request. If not provided, the session to target is decided by the endpoint.
662
+ * @returns @type {Promise} of @type {void} A Promise that resolves when the request is successfully handled,
663
+ * or rejects with an error if the request fails.
664
+ */
665
+ seek: (position: ITimeValue, sessionId?: IMediaSessionId) => Promise<void>;
666
+ /**
667
+ * Sends a set audio volume request on the media control endpoint.
668
+ * @param volume @type {number} The volume level to set. <are there constraints on this?>
669
+ * @param sessionId @type {IMediaSessionId} Optional. The session ID to target with
670
+ * the request. If not provided, the session to target is decided by the endpoint.
671
+ * @returns @type {Promise} of @type {void} A Promise that resolves when the request is successfully handled,
672
+ * or rejects with an error if the request fails.
673
+ */
674
+ setAudioVolume: (volume: number, sessionId?: IMediaSessionId) => Promise<void>;
675
+ /**
676
+ * Sends a setAudioTrack requst on the media control endpoint.
677
+ * @param track @type {ITrack} The track to set.
678
+ * @param sessionId @type {IMediaSessionId} Optional. The session ID to target with
679
+ * the request. If not provided, the session to target is decided by the endpoint.
680
+ * @returns @type {Promise} of @type {void} A Promise that resolves when the request is successfully handled,
681
+ * or rejects with an error if the request fails.
682
+ */
683
+ setAudioTrack: (track: ITrack, sessionId?: IMediaSessionId) => Promise<void>;
684
+ /**
685
+ * Sends a enableTextTrack request on the media control endpoint.
686
+ * @param track @type {ITrack} The track to enable.
687
+ * @param sessionId @type {IMediaSessionId} Optional. The session ID to target with
688
+ * the request. If not provided, the session to target is decided by the endpoint.
689
+ * @returns @type {Promise} of @type {void} A Promise that resolves when the request is successfully handled,
690
+ * or rejects with an error if the request fails.
691
+ */
692
+ enableTextTrack: (track: ITrack, sessionId?: IMediaSessionId) => Promise<void>;
693
+ /**
694
+ * Sends a disableTextTrack request on the media control endpoint.
695
+ * @param sessionId @type {IMediaSessionId} Optional. The session ID to target with
696
+ * the request. If not provided, the session to target is decided by the endpoint.
697
+ * @returns @type {Promise} of @type {void} A Promise that resolves when the request is successfully handled,
698
+ * or rejects with an error if the request fails.
699
+ */
700
+ disableTextTrack: (sessionId?: IMediaSessionId) => Promise<void>;
701
+ /**
702
+ * Sends a next request on the media control endpoint.
703
+ * @param sessionId @type {IMediaSessionId} Optional. The session ID to target with
704
+ * the request. If not provided, the session to target is decided by the endpoint.
705
+ * @returns @type {Promise} of @type {void} A Promise that resolves when the request is successfully handled,
706
+ * or rejects with an error if the request fails.
707
+ */
708
+ next: (sessionId?: IMediaSessionId) => Promise<void>;
709
+ /**
710
+ * Sends a previous request on the media control endpoint.
711
+ * @param sessionId @type {IMediaSessionId} Optional. The session ID to target with
712
+ * the request. If not provided, the session to target is decided by the endpoint.
713
+ * @returns @type {Promise} of @type {void} A Promise that resolves when the request is successfully handled,
714
+ * or rejects with an error if the request fails.
715
+ */
716
+ previous: (sessionId?: IMediaSessionId) => Promise<void>;
717
+ /**
718
+ * Sends a enableShuffle request on the media control endpoint.
719
+ * @param enable @type {boolean} When set to `true` shuffle is enabled; otherwise `false`.
720
+ * @param sessionId @type {IMediaSessionId} Optional. The session ID to target with
721
+ * the request. If not provided, the session to target is decided by the endpoint.
722
+ * @returns @type {Promise} of @type {void} A Promise that resolves when the request is successfully handled,
723
+ * or rejects with an error if the request fails.
724
+ */
725
+ enableShuffle: (enable: boolean, sessionId?: IMediaSessionId) => Promise<void>;
726
+ /**
727
+ * Sends a setRepeatMode request on the media control endpoint.
728
+ * @param mode @type {RepeatMode} The mode to set.
729
+ * @param sessionId @type {IMediaSessionId} Optional. The session ID to target with
730
+ * the request. If not provided, the session to target is decided by the endpoint.
731
+ * @returns @type {Promise} of @type {void} A Promise that resolves when the request is successfully handled,
732
+ * or rejects with an error if the request fails.
733
+ */
734
+ setRepeatMode: (mode: RepeatMode, sessionId?: IMediaSessionId) => Promise<void>;
735
+ /**
736
+ * Sends a setRating request on the media control endpoint.
737
+ * @param id @type {MediaId} The ID of the media.
738
+ * @param rating @type {number} The rating to set. <Are there contraints on this?>
739
+ * @param sessionId @type {IMediaSessionId} Optional. The session ID to target with
740
+ * the request. If not provided, the session to target is decided by the endpoint.
741
+ * @returns @type {Promise} of @type {void} A Promise that resolves when the request is successfully handled,
742
+ * or rejects with an error if the request fails.
743
+ */
744
+ setRating: (id: MediaId, rating: number, sessionId?: IMediaSessionId) => Promise<void>;
745
+ /**
746
+ * Sends a getMetadata request on the media control endpoint.
747
+ * @param id @type {MediaId} The ID of the media.
748
+ * @param sessionId @type {IMediaSessionId} Optional. The session ID to target with
749
+ * the request. If not provided, the session to target is decided by the endpoint.
750
+ * @returns @type {Promise} of @type {void} A Promise that resolves when the request is successfully handled,
751
+ * or rejects with an error if the request fails.
752
+ */
753
+ getMetadata: (id: MediaId) => Promise<IMediaMetadata>;
754
+ /**
755
+ * Sends a sendCustomAction request on the media control endpoint.
756
+ * @param action @type {Action} The action to send.
757
+ * @param sessionId @type {IMediaSessionId} Optional. The session ID to target with
758
+ * the request. If not provided, the session to target is decided by the endpoint.
759
+ * @returns @type {Promise} of @type {void} A Promise that resolves when the request is successfully handled,
760
+ * or rejects with an error if the request fails.
761
+ */
762
+ sendCustomAction: (action: Action, sessionId?: IMediaSessionId) => Promise<void>;
763
+ /**
764
+ * Sends a getSessionState request on the media control endpoint.
765
+ * @param sessionId @type {IMediaSessionId} Optional. The session ID to target with
766
+ * the request. If not provided, the request is interpretted to be for all available
767
+ * sessions.
768
+ * @returns @type {Promise} of @type {void} A Promise that resolves when the request is successfully handled,
769
+ * or rejects with an error if the request fails.
770
+ */
771
+ getSessionState: (sessionId?: IMediaSessionId) => Promise<MediaSessionState[]>;
772
+ /**
773
+ * Gets the package ID of this endpoint.
774
+ * @returns @type {IPackageId} The package ID.
775
+ */
776
+ getEndpointPackageId: () => IPackageId;
777
+ /**
778
+ * Subscribes a listener to monitor changes in the media session state.
779
+ * @param listener @type {IMediaControlListener} The listener to add.
780
+ * @returns @type {Promise} of @type {ISubscription} A Promise that resolves with an ISubscription object. This object can be used
781
+ * to unsubscribe the listener when it's no longer needed.
782
+ */
783
+ addListener: (listener: IMediaControlListener) => Promise<ISubscription>;
784
+ /**
785
+ * Destroys the media control client asynchronously.
786
+ */
787
+ destroy: () => void;
788
+ }
789
+ /**
790
+ * Represents a listener to add to monitor changes to the available media control endpoints.
791
+ */
792
+ export interface IMediaControlEndpointLocatorListener {
793
+ /**
794
+ * Called when the list of endpoints changes.
795
+ * @param controllers @type {IMediaControlClientAsync[]} An array of media control client endpoints
796
+ * that are available. The returned list is ordered with the first media control having active focus.
797
+ */
798
+ onEndpointsChanged: (controllers: IMediaControlClientAsync[]) => void;
799
+ }
800
+ /**
801
+ * Interface for asynchronously locating and interacting with media control endpoints.
802
+ */
803
+ export interface IMediaControlEndpointLocatorAsync {
804
+ /**
805
+ * Call to obtain a list of media control clients.
806
+ * @returns @type {Promise} of @type {MediaControlTypes.IMediaControlClientAsync[]} containing
807
+ * an ordered list of media control endpoints. The returned list is ordered with the first
808
+ * media control having active focus.
809
+ */
810
+ getMediaControlEndpoints: () => Promise<IMediaControlClientAsync[]>;
811
+ /**
812
+ * Subscribes a listener to monitor changes in the list of control endpoints.
813
+ * @param listener @type {MediaControlTypes.IMediaControlEndpointLocatorListener}
814
+ * @returns @type {Promise} of @type {MediaControlTypes.ISubscription} A Promise that
815
+ * resolves to an ISubscription object. The resolved ISubscription object provides
816
+ * a method to unsubscribe the listener when it's no longer need.
817
+ */
818
+ addChangeListener: (listener: IMediaControlEndpointLocatorListener) => Promise<ISubscription>;
819
+ }
820
+ /**
821
+ * Represent media control server operations.
822
+ * This interface provides methods for managing media control handlers and updating
823
+ * media session states.
824
+ *
825
+ */
826
+ export interface IMediaControlServerAsync {
827
+ /**
828
+ * Assigns a handler to process requests for media control actions for a given
829
+ * component.
830
+ *
831
+ * @param handler @type {IMediaConrolHandlerAsync} An instance of the `IMediaControlHandlerAsync` interface that
832
+ * manages media control actions.
833
+ * @param instance @type {IComponentInstance} An instance of the `IComponentInstance` interface representing
834
+ * the component for which the handler is being set.
835
+ *
836
+ * @remarks
837
+ * Assigning a handler is essential for processing media control requests and
838
+ * implementing custom media control logic.
839
+ *
840
+ * There is only one active handler at a time. The active handler is the one set by
841
+ * the most recent invocation of setHandler.
842
+ */
843
+ setHandlerForComponent: (handler: IMediaControlHandlerAsync, instance: IComponentInstance) => void;
844
+ /**
845
+ * Updates the state of the media sessions.
846
+ *
847
+ * @param states @type {MediaSessionState[]} Array of MediaSessionStates containing
848
+ * updated session states.
849
+ *
850
+ * @remarks
851
+ * Updating the session states is crucial for reflecting changes in media playback
852
+ * status, available media streams, and other related information.
853
+ *
854
+ * State changes can also be an action taken by a media control server application
855
+ * upon acting on an media control action received through the installed
856
+ * `IMediaControlHandlerAsync` instance.
857
+ */
858
+ updateMediaSessionStates: (states: MediaSessionState[]) => void;
859
+ }