@microsoft/live-share-media 1.0.0-preview.11 → 1.0.0-preview.12

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 (86) hide show
  1. package/README.md +1 -1
  2. package/bin/EphemeralMediaSession.d.ts +102 -0
  3. package/bin/EphemeralMediaSession.d.ts.map +1 -0
  4. package/bin/EphemeralMediaSession.js +226 -0
  5. package/bin/EphemeralMediaSession.js.map +1 -0
  6. package/bin/EphemeralMediaSessionCoordinator.d.ts +228 -0
  7. package/bin/EphemeralMediaSessionCoordinator.d.ts.map +1 -0
  8. package/bin/EphemeralMediaSessionCoordinator.js +396 -0
  9. package/bin/EphemeralMediaSessionCoordinator.js.map +1 -0
  10. package/bin/EphemeralMediaSessionCoordinatorSuspension.d.ts +20 -0
  11. package/bin/EphemeralMediaSessionCoordinatorSuspension.d.ts.map +1 -0
  12. package/bin/EphemeralMediaSessionCoordinatorSuspension.js +28 -0
  13. package/bin/EphemeralMediaSessionCoordinatorSuspension.js.map +1 -0
  14. package/bin/IMediaPlayer.d.ts +21 -0
  15. package/bin/IMediaPlayer.d.ts.map +1 -0
  16. package/bin/IMediaPlayer.js +7 -0
  17. package/bin/IMediaPlayer.js.map +1 -0
  18. package/bin/LiveMediaSession.d.ts +95 -0
  19. package/bin/LiveMediaSession.d.ts.map +1 -0
  20. package/bin/LiveMediaSession.js +232 -0
  21. package/bin/LiveMediaSession.js.map +1 -0
  22. package/bin/LiveMediaSessionCoordinator.d.ts +228 -0
  23. package/bin/LiveMediaSessionCoordinator.d.ts.map +1 -0
  24. package/bin/LiveMediaSessionCoordinator.js +408 -0
  25. package/bin/LiveMediaSessionCoordinator.js.map +1 -0
  26. package/bin/LiveMediaSessionCoordinatorSuspension.d.ts +20 -0
  27. package/bin/LiveMediaSessionCoordinatorSuspension.d.ts.map +1 -0
  28. package/bin/LiveMediaSessionCoordinatorSuspension.js +28 -0
  29. package/bin/LiveMediaSessionCoordinatorSuspension.js.map +1 -0
  30. package/bin/MediaPlayerSynchronizer.d.ts +164 -0
  31. package/bin/MediaPlayerSynchronizer.d.ts.map +1 -0
  32. package/bin/MediaPlayerSynchronizer.js +469 -0
  33. package/bin/MediaPlayerSynchronizer.js.map +1 -0
  34. package/bin/MediaSessionActionThrottler.d.ts +12 -0
  35. package/bin/MediaSessionActionThrottler.d.ts.map +1 -0
  36. package/bin/MediaSessionActionThrottler.js +14 -0
  37. package/bin/MediaSessionActionThrottler.js.map +1 -0
  38. package/bin/MediaSessionExtensions.d.ts +35 -0
  39. package/bin/MediaSessionExtensions.d.ts.map +1 -0
  40. package/bin/MediaSessionExtensions.js +13 -0
  41. package/bin/MediaSessionExtensions.js.map +1 -0
  42. package/bin/RepeatedActionThrottler.d.ts +20 -0
  43. package/bin/RepeatedActionThrottler.d.ts.map +1 -0
  44. package/bin/RepeatedActionThrottler.js +63 -0
  45. package/bin/RepeatedActionThrottler.js.map +1 -0
  46. package/bin/VolumeLimiter.d.ts +70 -0
  47. package/bin/VolumeLimiter.d.ts.map +1 -0
  48. package/bin/VolumeLimiter.js +170 -0
  49. package/bin/VolumeLimiter.js.map +1 -0
  50. package/bin/VolumeManager.d.ts +84 -0
  51. package/bin/VolumeManager.d.ts.map +1 -0
  52. package/bin/VolumeManager.js +175 -0
  53. package/bin/VolumeManager.js.map +1 -0
  54. package/bin/index.d.ts +14 -0
  55. package/bin/index.d.ts.map +1 -0
  56. package/bin/index.js +30 -0
  57. package/bin/index.js.map +1 -0
  58. package/bin/internals/GroupCoordinatorState.d.ts +93 -0
  59. package/bin/internals/GroupCoordinatorState.d.ts.map +1 -0
  60. package/bin/internals/GroupCoordinatorState.js +405 -0
  61. package/bin/internals/GroupCoordinatorState.js.map +1 -0
  62. package/bin/internals/GroupPlaybackPosition.d.ts +67 -0
  63. package/bin/internals/GroupPlaybackPosition.d.ts.map +1 -0
  64. package/bin/internals/GroupPlaybackPosition.js +167 -0
  65. package/bin/internals/GroupPlaybackPosition.js.map +1 -0
  66. package/bin/internals/GroupPlaybackTrack.d.ts +46 -0
  67. package/bin/internals/GroupPlaybackTrack.d.ts.map +1 -0
  68. package/bin/internals/GroupPlaybackTrack.js +122 -0
  69. package/bin/internals/GroupPlaybackTrack.js.map +1 -0
  70. package/bin/internals/GroupPlaybackTrackData.d.ts +40 -0
  71. package/bin/internals/GroupPlaybackTrackData.d.ts.map +1 -0
  72. package/bin/internals/GroupPlaybackTrackData.js +70 -0
  73. package/bin/internals/GroupPlaybackTrackData.js.map +1 -0
  74. package/bin/internals/GroupTransportState.d.ts +49 -0
  75. package/bin/internals/GroupTransportState.d.ts.map +1 -0
  76. package/bin/internals/GroupTransportState.js +112 -0
  77. package/bin/internals/GroupTransportState.js.map +1 -0
  78. package/bin/internals/consts.d.ts +73 -0
  79. package/bin/internals/consts.d.ts.map +1 -0
  80. package/bin/internals/consts.js +82 -0
  81. package/bin/internals/consts.js.map +1 -0
  82. package/bin/internals/index.d.ts +11 -0
  83. package/bin/internals/index.d.ts.map +1 -0
  84. package/bin/internals/index.js +27 -0
  85. package/bin/internals/index.js.map +1 -0
  86. package/package.json +3 -3
@@ -0,0 +1,408 @@
1
+ "use strict";
2
+ /**
3
+ * Copyright (c) Microsoft Corporation. All rights reserved.
4
+ * Licensed under the Microsoft Live Share SDK License.
5
+ */
6
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
7
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
8
+ return new (P || (P = Promise))(function (resolve, reject) {
9
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
10
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
11
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
12
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
13
+ });
14
+ };
15
+ var __importDefault = (this && this.__importDefault) || function (mod) {
16
+ return (mod && mod.__esModule) ? mod : { "default": mod };
17
+ };
18
+ Object.defineProperty(exports, "__esModule", { value: true });
19
+ exports.LiveMediaSessionCoordinator = void 0;
20
+ const live_share_1 = require("@microsoft/live-share");
21
+ const internals_1 = require("./internals");
22
+ const LiveMediaSessionCoordinatorSuspension_1 = require("./LiveMediaSessionCoordinatorSuspension");
23
+ const events_1 = __importDefault(require("events"));
24
+ /**
25
+ * The `LiveMediaSessionCoordinator` tracks the playback & position state of all other
26
+ * clients being synchronized with. It is responsible for keeping the local media player
27
+ * in sync with the group.
28
+ */
29
+ class LiveMediaSessionCoordinator extends events_1.default {
30
+ /**
31
+ * @hidden
32
+ * Applications shouldn't directly create new coordinator instances.
33
+ */
34
+ constructor(runtime, getPlayerState) {
35
+ super();
36
+ this._positionUpdateInterval = new live_share_1.TimeInterval(2000);
37
+ this._maxPlaybackDrift = new live_share_1.TimeInterval(1000);
38
+ this._hasInitialized = false;
39
+ /**
40
+ * Controls whether or not the local client is allowed to instruct the group to play or pause.
41
+ *
42
+ * @remarks
43
+ * This flag largely meant to influence decisions made by the coordinator and can be used by
44
+ * the UI to determine what controls should be shown to the user. It does not provide any
45
+ * security in itself.
46
+ *
47
+ * If your app is running in a semi-trusted environment where only some clients are allowed
48
+ * to play/pause media, you should use "role based verification" to enforce those policies.
49
+ */
50
+ this.canPlayPause = true;
51
+ /**
52
+ * Controls whether or not the local client is allowed to seek the group to a new playback
53
+ * position.
54
+ *
55
+ * @remarks
56
+ * This flag largely meant to influence decisions made by the coordinator and can be used by
57
+ * the UI to determine what controls should be shown to the user. It does not provide any
58
+ * security in itself.
59
+ *
60
+ * If your app is running in a semi-trusted environment where only some clients are allowed
61
+ * to change the playback position, you should use "role based verification" to enforce those policies.
62
+ */
63
+ this.canSeek = true;
64
+ /**
65
+ * Controls whether or not the local client is allowed to change tracks.
66
+ *
67
+ * @remarks
68
+ * This flag largely meant to influence decisions made by the coordinator and can be used by
69
+ * the UI to determine what controls should be shown to the user. It does not provide any
70
+ * security in itself.
71
+ *
72
+ * If your app is running in a semi-trusted environment where only some clients are allowed
73
+ * to change tracks, you should use "role based verification" to enforce those policies.
74
+ */
75
+ this.canSetTrack = true;
76
+ /**
77
+ * Controls whether or not the local client is allowed to change the tracks custom data object.
78
+ *
79
+ * @remarks
80
+ * This flag largely meant to influence decisions made by the coordinator and can be used by
81
+ * the UI to determine what controls should be shown to the user. It does not provide any
82
+ * security in itself.
83
+ *
84
+ * If your app is running in a semi-trusted environment where only some clients are allowed
85
+ * to change the tracks data object, you should use "role based verification" to enforce those
86
+ * policies.
87
+ */
88
+ this.canSetTrackData = true;
89
+ this._runtime = runtime;
90
+ this._logger = new live_share_1.LiveTelemetryLogger(runtime);
91
+ this._getPlayerState = getPlayerState;
92
+ }
93
+ /**
94
+ * Returns true if the local client is in a suspended state.
95
+ */
96
+ get isSuspended() {
97
+ return this._groupState ? this._groupState.isSuspended : false;
98
+ }
99
+ /**
100
+ * Max amount of playback drift allowed in seconds.
101
+ *
102
+ * @remarks
103
+ * Should the local clients playback position lag by more than the specified value, the
104
+ * coordinator will trigger a `catchup` action.
105
+ *
106
+ * Defaults to a value of `1` second.
107
+ */
108
+ get maxPlaybackDrift() {
109
+ return this._maxPlaybackDrift.seconds;
110
+ }
111
+ set maxPlaybackDrift(value) {
112
+ this._maxPlaybackDrift.seconds = value;
113
+ }
114
+ /**
115
+ * Frequency with which position updates are broadcast to the rest of the group in
116
+ * seconds.
117
+ *
118
+ * @remarks
119
+ * Defaults to a value of `2` seconds.
120
+ */
121
+ get positionUpdateInterval() {
122
+ return this._positionUpdateInterval.seconds;
123
+ }
124
+ set positionUpdateInterval(value) {
125
+ this._positionUpdateInterval.seconds = value;
126
+ }
127
+ /**
128
+ * Instructs the group to play the current track.
129
+ *
130
+ * @remarks
131
+ * Throws an exception if the session/coordinator hasn't been initialized, no track has been
132
+ * loaded, or `canPlayPause` is false.
133
+ */
134
+ play() {
135
+ var _a;
136
+ if (!this._hasInitialized) {
137
+ throw new Error(`LiveMediaSessionCoordinator.play() called before initialize() called.`);
138
+ }
139
+ if (!((_a = this._groupState) === null || _a === void 0 ? void 0 : _a.playbackTrack.current.metadata)) {
140
+ throw new Error(`LiveMediaSessionCoordinator.play() called before MediaSession.metadata assigned.`);
141
+ }
142
+ if (!this.canPlayPause) {
143
+ throw new Error(`LiveMediaSessionCoordinator.play() operation blocked.`);
144
+ }
145
+ // Get projected position
146
+ const position = this.getPlayerPosition();
147
+ // Send transport command
148
+ this._logger.sendTelemetryEvent(internals_1.TelemetryEvents.SessionCoordinator.PlayCalled, null, { position: position });
149
+ this._playEvent.sendEvent({
150
+ track: this._groupState.playbackTrack.current,
151
+ position: position,
152
+ });
153
+ }
154
+ /**
155
+ * Instructs the group to pause the current track.
156
+ *
157
+ * @remarks
158
+ * Throws an exception if the session/coordinator hasn't been initialized, no track has been
159
+ * loaded, or `canPlayPause` is false.
160
+ */
161
+ pause() {
162
+ var _a;
163
+ if (!this._hasInitialized) {
164
+ throw new Error(`LiveMediaSessionCoordinator.pause() called before initialize() called.`);
165
+ }
166
+ if (!((_a = this._groupState) === null || _a === void 0 ? void 0 : _a.playbackTrack.current.metadata)) {
167
+ throw new Error(`LiveMediaSessionCoordinator.pause() called before MediaSession.metadata assigned.`);
168
+ }
169
+ if (!this.canPlayPause) {
170
+ throw new Error(`LiveMediaSessionCoordinator.pause() operation blocked.`);
171
+ }
172
+ // Get projected position
173
+ const position = this.getPlayerPosition();
174
+ // Send transport command
175
+ this._logger.sendTelemetryEvent(internals_1.TelemetryEvents.SessionCoordinator.PauseCalled, null, { position: position });
176
+ this._pauseEvent.sendEvent({
177
+ track: this._groupState.playbackTrack.current,
178
+ position: position,
179
+ });
180
+ }
181
+ /**
182
+ * Instructs the group to seek to a new position within the current track.
183
+ *
184
+ * @remarks
185
+ * Throws an exception if the session/coordinator hasn't been initialized, no track has been
186
+ * loaded, or `canSeek` is false.
187
+ * @param time Playback position in seconds to seek to.
188
+ */
189
+ seekTo(time) {
190
+ var _a;
191
+ if (!this._hasInitialized) {
192
+ throw new Error(`LiveMediaSessionCoordinator.seekTo() called before initialize() called.`);
193
+ }
194
+ if (!((_a = this._groupState) === null || _a === void 0 ? void 0 : _a.playbackTrack.current.metadata)) {
195
+ throw new Error(`LiveMediaSessionCoordinator.seekTo() called before MediaSession.metadata assigned.`);
196
+ }
197
+ if (!this.canSeek) {
198
+ throw new Error(`LiveMediaSessionCoordinator.seekTo() operation blocked.`);
199
+ }
200
+ // Send transport command
201
+ this._logger.sendTelemetryEvent(internals_1.TelemetryEvents.SessionCoordinator.SeekToCalled, null, { position: time });
202
+ this._seekToEvent.sendEvent({
203
+ track: this._groupState.playbackTrack.current,
204
+ position: time,
205
+ });
206
+ }
207
+ /**
208
+ * Instructs the group to load a new track.
209
+ *
210
+ * @remarks
211
+ * Throws an exception if the session/coordinator hasn't been initialized or `canSetTrack` is
212
+ * false.
213
+ * @param metadata The track to load or `null` to indicate that the end of the track is reached.
214
+ * @param waitPoints Optional. List of static wait points to configure for the track. Dynamic wait points can be added via the `beginSuspension()` call.
215
+ */
216
+ setTrack(metadata, waitPoints) {
217
+ if (!this._hasInitialized) {
218
+ throw new Error(`LiveMediaSessionCoordinator.setTrack() called before initialize() called.`);
219
+ }
220
+ if (!this.canSetTrack) {
221
+ throw new Error(`LiveMediaSessionCoordinator.setTrack() operation blocked.`);
222
+ }
223
+ // Send transport command
224
+ this._logger.sendTelemetryEvent(internals_1.TelemetryEvents.SessionCoordinator.SetTrackCalled);
225
+ this._setTrackEvent.sendEvent({
226
+ metadata: metadata,
227
+ waitPoints: waitPoints || [],
228
+ });
229
+ }
230
+ /**
231
+ * Updates the track data object for the current track.
232
+ *
233
+ * @remarks
234
+ * The track data object can be used by applications to synchronize things like pitch, roll,
235
+ * and yaw of a 360 video. This data object will be reset to null anytime the track changes.
236
+ *
237
+ * Throws an exception if the session/coordinator hasn't been initialized or `canSetTrackData` is
238
+ * false.
239
+ * @param data New data object to sync with the group. This value will be synchronized using a last writer wins strategy.
240
+ */
241
+ setTrackData(data) {
242
+ if (!this._hasInitialized) {
243
+ throw new Error(`LiveMediaSessionCoordinator.setTrackData() called before initialize() called.`);
244
+ }
245
+ if (!this.canSetTrackData) {
246
+ throw new Error(`LiveMediaSessionCoordinator.setTrackData() operation blocked.`);
247
+ }
248
+ // Send transport command
249
+ this._logger.sendTelemetryEvent(internals_1.TelemetryEvents.SessionCoordinator.SetTrackDataCalled);
250
+ this._setTrackDataEvent.sendEvent({
251
+ data: data,
252
+ });
253
+ }
254
+ /**
255
+ * Begins a new local suspension.
256
+ *
257
+ * @remarks
258
+ * Suspension temporarily suspend the clients local synchronization with the group. This can
259
+ * be useful for displaying ads to users or temporarily disconnecting from the session while
260
+ * the user seeks the video using a timeline scrubber.
261
+ *
262
+ * Multiple simultaneous suspensions are allowed and when the last suspension ends the local
263
+ * client will be immediately re-synchronized with the group.
264
+ *
265
+ * A "Dynamic Wait Point" can be specified when `beginSuspension()` is called and the wait
266
+ * point will be broadcast to all other clients in the group. Those clients will then
267
+ * automatically enter a suspension state once they reach the positions specified by the
268
+ * wait point. Clients that are passed the wait point will immediately suspend.
269
+ *
270
+ * Any wait point based suspension (dynamic or static) will result in all clients remaining
271
+ * in a suspension state until the list client ends their suspension. This behavior can be
272
+ * conditionally bypassed by settings the wait points `maxClients` value.
273
+ *
274
+ * Throws an exception if the session/coordinator hasn't been initialized.
275
+ * @param waitPoint Optional. Dynamic wait point to broadcast to all of the clients.
276
+ * @returns The suspension object. Call `end()` on the returned suspension to end the suspension.
277
+ */
278
+ beginSuspension(waitPoint) {
279
+ var _a;
280
+ if (!this._hasInitialized) {
281
+ throw new Error(`LiveMediaSessionCoordinator.beginSuspension() called before initialize() called.`);
282
+ }
283
+ if (!((_a = this._groupState) === null || _a === void 0 ? void 0 : _a.playbackTrack.current.metadata)) {
284
+ throw new Error(`LiveMediaSessionCoordinator.beginSuspension() called before MediaSession.metadata assigned.`);
285
+ }
286
+ // Tell group state that suspension is started
287
+ if (waitPoint) {
288
+ this._logger.sendTelemetryEvent(internals_1.TelemetryEvents.SessionCoordinator.BeginSuspensionAndWait, null, {
289
+ position: waitPoint.position,
290
+ maxClients: waitPoint.maxClients,
291
+ });
292
+ this._lastWaitPoint = waitPoint;
293
+ this._groupState.beginSuspension(waitPoint);
294
+ }
295
+ else {
296
+ this._logger.sendTelemetryEvent(internals_1.TelemetryEvents.SessionCoordinator.BeginSuspension);
297
+ this._groupState.beginSuspension();
298
+ }
299
+ // Return new suspension object
300
+ return new LiveMediaSessionCoordinatorSuspension_1.LiveMediaSessionCoordinatorSuspension(waitPoint, (time) => {
301
+ var _a, _b;
302
+ if (waitPoint) {
303
+ this._logger.sendTelemetryEvent(internals_1.TelemetryEvents.SessionCoordinator.EndSuspensionAndWait, null, {
304
+ position: waitPoint.position,
305
+ maxClients: waitPoint.maxClients,
306
+ });
307
+ }
308
+ else {
309
+ this._logger.sendTelemetryEvent(internals_1.TelemetryEvents.SessionCoordinator.EndSuspension);
310
+ }
311
+ this._groupState.endSuspension(time == undefined);
312
+ if (time != undefined &&
313
+ !((_a = this._groupState) === null || _a === void 0 ? void 0 : _a.isSuspended) &&
314
+ !((_b = this._groupState) === null || _b === void 0 ? void 0 : _b.isWaiting)) {
315
+ // Seek to new position
316
+ this.seekTo(Math.max(time, 0.0));
317
+ }
318
+ });
319
+ }
320
+ /**
321
+ * @hidden
322
+ * Called by MediaSession to verify the coordinator has been initialized.
323
+ */
324
+ get isInitialized() {
325
+ return this._hasInitialized;
326
+ }
327
+ /**
328
+ * @hidden
329
+ * Called by MediaSession to start coordinator.
330
+ */
331
+ initialize(acceptTransportChangesFrom) {
332
+ return __awaiter(this, void 0, void 0, function* () {
333
+ if (this._hasInitialized) {
334
+ throw new Error(`LiveMediaSessionCoordinator.initialize() already initialized.`);
335
+ }
336
+ // Create children
337
+ yield this.createChildren(acceptTransportChangesFrom);
338
+ this._hasInitialized = true;
339
+ });
340
+ }
341
+ /**
342
+ * @hidden
343
+ * Called by the MediaSession to detect if a wait point has been hit.
344
+ */
345
+ findNextWaitPoint() {
346
+ var _a;
347
+ return (((_a = this._groupState) === null || _a === void 0 ? void 0 : _a.playbackTrack.findNextWaitPoint(this._lastWaitPoint)) || null);
348
+ }
349
+ /**
350
+ * @hidden
351
+ * Called by MediaSession to trigger the sending of a position update.
352
+ */
353
+ sendPositionUpdate(state) {
354
+ var _a;
355
+ if (!this._hasInitialized) {
356
+ throw new Error(`LiveMediaSessionCoordinator.sendPositionUpdate() called before initialize() called.`);
357
+ }
358
+ // Send position update event
359
+ const evt = this._groupState.createPositionUpdateEvent(state);
360
+ (_a = this._positionUpdateEvent) === null || _a === void 0 ? void 0 : _a.sendEvent(evt);
361
+ }
362
+ createChildren(acceptTransportChangesFrom) {
363
+ return __awaiter(this, void 0, void 0, function* () {
364
+ // Create event scopes
365
+ const scope = new live_share_1.LiveEventScope(this._runtime, acceptTransportChangesFrom);
366
+ const unrestrictedScope = new live_share_1.LiveEventScope(this._runtime);
367
+ // Initialize internal coordinator state
368
+ this._groupState = new internals_1.GroupCoordinatorState(this._runtime, this._maxPlaybackDrift, this._positionUpdateInterval, this._getPlayerState);
369
+ this._groupState.on(internals_1.GroupCoordinatorStateEvents.triggeraction, (evt) => this.emit(evt.name, evt));
370
+ // Listen for track changes
371
+ this._setTrackEvent = new live_share_1.LiveEventTarget(scope, "setTrack", (event, local) => this._groupState.handleSetTrack(event, local));
372
+ this._setTrackDataEvent = new live_share_1.LiveEventTarget(scope, "setTrackData", (event, local) => this._groupState.handleSetTrackData(event, local));
373
+ // Listen for transport commands
374
+ this._playEvent = new live_share_1.LiveEventTarget(scope, "play", (event, local) => this._groupState.handleTransportCommand(event, local));
375
+ this._pauseEvent = new live_share_1.LiveEventTarget(scope, "pause", (event, local) => this._groupState.handleTransportCommand(event, local));
376
+ this._seekToEvent = new live_share_1.LiveEventTarget(scope, "seekTo", (event, local) => this._groupState.handleTransportCommand(event, local));
377
+ // Listen for position updates
378
+ this._positionUpdateEvent = new live_share_1.LiveEventTarget(unrestrictedScope, "positionUpdate", (event, local) => this._groupState.handlePositionUpdate(event, local));
379
+ // Listen for joined event
380
+ this._joinedEvent = new live_share_1.LiveEventTarget(unrestrictedScope, "joined", (evt, local) => {
381
+ var _a;
382
+ // Immediately send a position update
383
+ this._logger.sendTelemetryEvent(internals_1.TelemetryEvents.SessionCoordinator.RemoteJoinReceived, null, {
384
+ correlationId: live_share_1.LiveTelemetryLogger.formatCorrelationId(evt.clientId, evt.timestamp),
385
+ });
386
+ const state = this._getPlayerState();
387
+ const update = this._groupState.createPositionUpdateEvent(state);
388
+ (_a = this._positionUpdateEvent) === null || _a === void 0 ? void 0 : _a.sendEvent(update);
389
+ });
390
+ // Send initial joined event
391
+ this._joinedEvent.sendEvent({});
392
+ });
393
+ }
394
+ getPlayerPosition() {
395
+ const { positionState, playbackState } = this._getPlayerState();
396
+ switch (playbackState) {
397
+ case "none":
398
+ case "ended":
399
+ return 0.0;
400
+ default:
401
+ return positionState && positionState.position != undefined
402
+ ? positionState.position
403
+ : 0.0;
404
+ }
405
+ }
406
+ }
407
+ exports.LiveMediaSessionCoordinator = LiveMediaSessionCoordinator;
408
+ //# sourceMappingURL=LiveMediaSessionCoordinator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LiveMediaSessionCoordinator.js","sourceRoot":"","sources":["../src/LiveMediaSessionCoordinator.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;;;;;;;AAEH,sDAQ+B;AAU/B,2CASqB;AACrB,mGAAgG;AAChG,oDAAkC;AA8BlC;;;;GAIG;AACH,MAAa,2BAA4B,SAAQ,gBAAY;IAqBzD;;;OAGG;IACH,YACI,OAAyB,EACzB,cAAuC;QAEvC,KAAK,EAAE,CAAC;QAzBJ,4BAAuB,GAAG,IAAI,yBAAY,CAAC,IAAI,CAAC,CAAC;QACjD,sBAAiB,GAAG,IAAI,yBAAY,CAAC,IAAI,CAAC,CAAC;QAE3C,oBAAe,GAAG,KAAK,CAAC;QA4BhC;;;;;;;;;;WAUG;QACI,iBAAY,GAAY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AC;gBACrC,MAAM,MAAM,GACR,IAAI,CAAC,WAAY,CAAC,yBAAyB,CAAC,KAAK,CAAC,CAAC;gBACvD,MAAA,IAAI,CAAC,oBAAoB,0CAAE,SAAS,CAAC,MAAM,CAAC,CAAC;YACjD,CAAC,CACJ,CAAC;YAEF,4BAA4B;YAC5B,IAAI,CAAC,YAAY,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC;QACpC,CAAC;KAAA;IAEO,iBAAiB;QACrB,MAAM,EAAE,aAAa,EAAE,aAAa,EAAE,GAAG,IAAI,CAAC,eAAe,EAAE,CAAC;QAChE,QAAQ,aAAa,EAAE;YACnB,KAAK,MAAM,CAAC;YACZ,KAAK,OAAO;gBACR,OAAO,GAAG,CAAC;YACf;gBACI,OAAO,aAAa,IAAI,aAAa,CAAC,QAAQ,IAAI,SAAS;oBACvD,CAAC,CAAC,aAAa,CAAC,QAAQ;oBACxB,CAAC,CAAC,GAAG,CAAC;SACjB;IACL,CAAC;CACJ;AAviBD,kEAuiBC"}
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Copyright (c) Microsoft Corporation. All rights reserved.
3
+ * Licensed under the Microsoft Live Share SDK License.
4
+ */
5
+ import { MediaSessionCoordinatorSuspension, CoordinationWaitPoint } from "./MediaSessionExtensions";
6
+ export declare class LiveMediaSessionCoordinatorSuspension implements MediaSessionCoordinatorSuspension {
7
+ private _waitPoint?;
8
+ private _onEnd;
9
+ constructor(waitPoint: CoordinationWaitPoint | undefined, onEnd: (seekTo?: number) => void);
10
+ /**
11
+ * Returns an optional wait point associated with the suspension.
12
+ */
13
+ get waitPoint(): CoordinationWaitPoint | undefined;
14
+ /**
15
+ * Ends the suspension and optionally proposes a time to seek to.
16
+ * @param seekTo Optional. Proposed time to seek to. Ignored for suspensions at wait points.
17
+ */
18
+ end(seekTo?: number): void;
19
+ }
20
+ //# sourceMappingURL=LiveMediaSessionCoordinatorSuspension.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LiveMediaSessionCoordinatorSuspension.d.ts","sourceRoot":"","sources":["../src/LiveMediaSessionCoordinatorSuspension.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACH,iCAAiC,EACjC,qBAAqB,EACxB,MAAM,0BAA0B,CAAC;AAElC,qBAAa,qCACT,YAAW,iCAAiC;IAE5C,OAAO,CAAC,UAAU,CAAC,CAAwB;IAC3C,OAAO,CAAC,MAAM,CAA4B;gBAGtC,SAAS,EAAE,qBAAqB,GAAG,SAAS,EAC5C,KAAK,EAAE,CAAC,MAAM,CAAC,EAAE,MAAM,KAAK,IAAI;IAMpC;;OAEG;IACH,IAAW,SAAS,IAAI,qBAAqB,GAAG,SAAS,CAExD;IAED;;;OAGG;IACI,GAAG,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI;CAGpC"}
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ /**
3
+ * Copyright (c) Microsoft Corporation. All rights reserved.
4
+ * Licensed under the Microsoft Live Share SDK License.
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.LiveMediaSessionCoordinatorSuspension = void 0;
8
+ class LiveMediaSessionCoordinatorSuspension {
9
+ constructor(waitPoint, onEnd) {
10
+ this._waitPoint = waitPoint;
11
+ this._onEnd = onEnd;
12
+ }
13
+ /**
14
+ * Returns an optional wait point associated with the suspension.
15
+ */
16
+ get waitPoint() {
17
+ return this._waitPoint;
18
+ }
19
+ /**
20
+ * Ends the suspension and optionally proposes a time to seek to.
21
+ * @param seekTo Optional. Proposed time to seek to. Ignored for suspensions at wait points.
22
+ */
23
+ end(seekTo) {
24
+ this._onEnd(seekTo);
25
+ }
26
+ }
27
+ exports.LiveMediaSessionCoordinatorSuspension = LiveMediaSessionCoordinatorSuspension;
28
+ //# sourceMappingURL=LiveMediaSessionCoordinatorSuspension.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LiveMediaSessionCoordinatorSuspension.js","sourceRoot":"","sources":["../src/LiveMediaSessionCoordinatorSuspension.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAOH,MAAa,qCAAqC;IAM9C,YACI,SAA4C,EAC5C,KAAgC;QAEhC,IAAI,CAAC,UAAU,GAAG,SAAS,CAAC;QAC5B,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;IACxB,CAAC;IAED;;OAEG;IACH,IAAW,SAAS;QAChB,OAAO,IAAI,CAAC,UAAU,CAAC;IAC3B,CAAC;IAED;;;OAGG;IACI,GAAG,CAAC,MAAe;QACtB,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IACxB,CAAC;CACJ;AA5BD,sFA4BC"}
@@ -0,0 +1,164 @@
1
+ /// <reference types="node" />
2
+ /**
3
+ * Copyright (c) Microsoft Corporation. All rights reserved.
4
+ * Licensed under the Microsoft Live Share SDK License.
5
+ */
6
+ import { IEvent } from "@microsoft/live-share";
7
+ import EventEmitter from "events";
8
+ import { ExtendedMediaMetadata, CoordinationWaitPoint, ExtendedMediaSessionActionDetails } from "./MediaSessionExtensions";
9
+ import { VolumeManager } from "./VolumeManager";
10
+ import { LiveMediaSession } from "./LiveMediaSession";
11
+ import { IMediaPlayer } from "./IMediaPlayer";
12
+ /**
13
+ * Event data returned by `MediaPlayerSynchronizer` object.
14
+ */
15
+ export interface IMediaPlayerSynchronizerEvent extends IEvent {
16
+ /**
17
+ * Event details.
18
+ */
19
+ details: ExtendedMediaSessionActionDetails;
20
+ /**
21
+ * Action errors, including DOMException errors thrown by HTMLMediaElement
22
+ */
23
+ error?: Error;
24
+ }
25
+ /**
26
+ * Events supported by `MediaPlayerSynchronizer` object.
27
+ */
28
+ export declare enum MediaPlayerSynchronizerEvents {
29
+ /**
30
+ *
31
+ */
32
+ coordinatorstatechange = "coordinatorstatechange",
33
+ groupaction = "groupaction",
34
+ useraction = "useraction"
35
+ }
36
+ /**
37
+ * Synchronizes a local HTML Media Element with a group of remote HTML Media Elements.
38
+ *
39
+ * @remarks
40
+ * All of an apps transport control commands should be routed through the synchronizer. If the
41
+ * app is not currently joined to the group media session, the commands will be applied directly
42
+ * to the local player. When the group session is joined the commands will be broadcast to the
43
+ * group in addition to being applied to the local player.
44
+ */
45
+ export declare class MediaPlayerSynchronizer extends EventEmitter {
46
+ private static SESSION_ACTIONS;
47
+ private static PLAYER_EVENTS;
48
+ private _logger;
49
+ private _player;
50
+ private _mediaSession;
51
+ private _volumeManager;
52
+ private _onEnd?;
53
+ private _onPlayerEvent;
54
+ private _seekSuspension?;
55
+ private _viewOnly;
56
+ private _expectedPlaybackState;
57
+ private _trackData;
58
+ /**
59
+ * Creates a new `MediaElementSynchronizer` instance.
60
+ * @param player Media player element. This can be an HTML Media Element or any player that looks like an HTML Media Element.
61
+ * @param mediaSession Group MediaSession object being used.
62
+ * @param onEnd Optional. Function to call when synchronizers `end()` method is called.
63
+ */
64
+ constructor(player: IMediaPlayer, mediaSession: LiveMediaSession, onEnd: () => void);
65
+ /**
66
+ * Media player being synchronized.
67
+ */
68
+ get player(): IMediaPlayer;
69
+ /**
70
+ * Synchronizers media session.
71
+ */
72
+ get mediaSession(): LiveMediaSession;
73
+ /**
74
+ * If true the client is in a view only mode.
75
+ *
76
+ * @remarks
77
+ * Toggling this value to true results in `mediaSession.coordinator.canPlayPause`,
78
+ * `mediaSession.coordinator.canSeek`, `mediaSession.coordinator.canSetTrack`, and
79
+ * `mediaSession.coordinator.canSetTrackData` all being set to false. For more fine
80
+ * grained control over the local clients policies, call the `mediaSession.coordinator`
81
+ * directly.
82
+ */
83
+ get viewOnly(): boolean;
84
+ set viewOnly(value: boolean);
85
+ /**
86
+ * Volume limiter used to temporarily reduce the videos volume when someone speaks in a meeting.
87
+ */
88
+ get volumeManager(): VolumeManager;
89
+ /**
90
+ * Registers a new event listener.
91
+ * @param event Name of the event to add.
92
+ * @param listener Function to call when the event is triggered.
93
+ */
94
+ addEventListener(event: MediaPlayerSynchronizerEvents, listener: (evt: IMediaPlayerSynchronizerEvent) => void): this;
95
+ /**
96
+ * Un-registers an existing event listener.
97
+ * @param event Name of the event to remove.
98
+ * @param listener Function that was registered in call to `addEventListener()`.
99
+ */
100
+ removeEventListener(event: MediaPlayerSynchronizerEvents, listener: (evt: IMediaPlayerSynchronizerEvent) => void): this;
101
+ /**
102
+ * Ends synchronization of the current media player.
103
+ */
104
+ end(): void;
105
+ /**
106
+ * Begin a local seek operation.
107
+ *
108
+ * @remarks
109
+ * UI can call this when a user grabs a timeline scrubber and starts scrubbing the video to a
110
+ * new playback position. The synchronizer will being a new suspension which temporarily
111
+ * disconnects the client for the rest of the group for synchronization purposes. Calling
112
+ * `endSeek()` will end the suspension and seek the group to the users final seek position.
113
+ */
114
+ beginSeek(): void;
115
+ /**
116
+ * Ends a seek operation that was started by calling `beginSeek()`.
117
+ * @param seekTo Playback position in seconds to seek the group to.
118
+ */
119
+ endSeek(seekTo: number): void;
120
+ /**
121
+ * Tells the group to begin playing the current video.
122
+ *
123
+ * @remarks
124
+ * For proper operation apps should avoid calling `mediaSession.coordinator.play()` directly
125
+ * and instead use the synchronizers `play()` method.
126
+ */
127
+ play(): void;
128
+ /**
129
+ * Tells the group to pause the current video.
130
+ *
131
+ * @remarks
132
+ * For proper operation apps should avoid calling `mediaSession.coordinator.pause()` directly
133
+ * and instead use the synchronizers `pause()` method.
134
+ */
135
+ pause(): void;
136
+ /**
137
+ * Tells the group to seek the current video to a new playback position.
138
+ *
139
+ * @remarks
140
+ * For proper operation apps should avoid calling `mediaSession.coordinator.seekTo()` directly
141
+ * and instead use the synchronizers `seekTo()` method.
142
+ */
143
+ seekTo(time: number): void;
144
+ /**
145
+ * Tells the group to change to a new track.
146
+ *
147
+ * @remarks
148
+ * For proper operation apps should avoid calling `mediaSession.coordinator.setTrack()` directly
149
+ * and instead use the synchronizers `setTrack()` method.
150
+ */
151
+ setTrack(track: ExtendedMediaMetadata, waitPoints?: CoordinationWaitPoint[]): void;
152
+ /**
153
+ * Updates the current tracks data object.
154
+ *
155
+ * @remarks
156
+ * For proper operation apps should avoid calling `mediaSession.coordinator.setTrackData()` directly
157
+ * and instead use the synchronizers `setTrackData()` method.
158
+ */
159
+ setTrackData(data: object | null): void;
160
+ private dispatchGroupAction;
161
+ private dispatchUserAction;
162
+ private catchupPlayer;
163
+ }
164
+ //# sourceMappingURL=MediaPlayerSynchronizer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MediaPlayerSynchronizer.d.ts","sourceRoot":"","sources":["../src/MediaPlayerSynchronizer.ts"],"names":[],"mappings":";AAAA;;;GAGG;AACH,OAAO,EAAuB,MAAM,EAAE,MAAM,uBAAuB,CAAC;AACpE,OAAO,YAAY,MAAM,QAAQ,CAAC;AAClC,OAAO,EAGH,qBAAqB,EACrB,qBAAqB,EACrB,iCAAiC,EAGpC,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAG9C;;GAEG;AACH,MAAM,WAAW,6BAA8B,SAAQ,MAAM;IACzD;;OAEG;IACH,OAAO,EAAE,iCAAiC,CAAC;IAC3C;;OAEG;IACH,KAAK,CAAC,EAAE,KAAK,CAAC;CACjB;AAED;;GAEG;AACH,oBAAY,6BAA6B;IACrC;;OAEG;IACH,sBAAsB,2BAA2B;IACjD,WAAW,gBAAgB;IAC3B,UAAU,eAAe;CAC5B;AAED;;;;;;;;GAQG;AACH,qBAAa,uBAAwB,SAAQ,YAAY;IACrD,OAAO,CAAC,MAAM,CAAC,eAAe,CAQ5B;IACF,OAAO,CAAC,MAAM,CAAC,aAAa,CAQ1B;IAEF,OAAO,CAAC,OAAO,CAAsB;IACrC,OAAO,CAAC,OAAO,CAAe;IAC9B,OAAO,CAAC,aAAa,CAAmB;IACxC,OAAO,CAAC,cAAc,CAAgB;IACtC,OAAO,CAAC,MAAM,CAAC,CAAa;IAC5B,OAAO,CAAC,cAA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