@microsoft/live-share-media 1.0.0-preview.8 → 1.0.0

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/LICENSE +64 -61
  2. package/README.md +11 -15
  3. package/bin/IMediaPlayer.d.ts +20 -20
  4. package/bin/IMediaPlayer.js +6 -6
  5. package/bin/LiveMediaSession.d.ts +90 -94
  6. package/bin/LiveMediaSession.d.ts.map +1 -1
  7. package/bin/LiveMediaSession.js +228 -231
  8. package/bin/LiveMediaSession.js.map +1 -1
  9. package/bin/LiveMediaSessionCoordinator.d.ts +238 -227
  10. package/bin/LiveMediaSessionCoordinator.d.ts.map +1 -1
  11. package/bin/LiveMediaSessionCoordinator.js +476 -407
  12. package/bin/LiveMediaSessionCoordinator.js.map +1 -1
  13. package/bin/LiveMediaSessionCoordinatorSuspension.d.ts +19 -19
  14. package/bin/LiveMediaSessionCoordinatorSuspension.js +27 -27
  15. package/bin/MediaPlayerSynchronizer.d.ts +173 -163
  16. package/bin/MediaPlayerSynchronizer.d.ts.map +1 -1
  17. package/bin/MediaPlayerSynchronizer.js +491 -468
  18. package/bin/MediaPlayerSynchronizer.js.map +1 -1
  19. package/bin/MediaSessionActionThrottler.d.ts +11 -11
  20. package/bin/MediaSessionActionThrottler.js +13 -13
  21. package/bin/MediaSessionExtensions.d.ts +34 -34
  22. package/bin/MediaSessionExtensions.d.ts.map +1 -1
  23. package/bin/MediaSessionExtensions.js +12 -12
  24. package/bin/RepeatedActionThrottler.d.ts +19 -19
  25. package/bin/RepeatedActionThrottler.js +62 -62
  26. package/bin/RepeatedActionThrottler.js.map +1 -1
  27. package/bin/VolumeManager.d.ts +83 -83
  28. package/bin/VolumeManager.js +174 -174
  29. package/bin/index.d.ts +13 -13
  30. package/bin/index.js +29 -29
  31. package/bin/internals/GroupCoordinatorState.d.ts +93 -92
  32. package/bin/internals/GroupCoordinatorState.d.ts.map +1 -1
  33. package/bin/internals/GroupCoordinatorState.js +407 -404
  34. package/bin/internals/GroupCoordinatorState.js.map +1 -1
  35. package/bin/internals/GroupPlaybackPosition.d.ts +67 -66
  36. package/bin/internals/GroupPlaybackPosition.d.ts.map +1 -1
  37. package/bin/internals/GroupPlaybackPosition.js +166 -166
  38. package/bin/internals/GroupPlaybackPosition.js.map +1 -1
  39. package/bin/internals/GroupPlaybackTrack.d.ts +45 -45
  40. package/bin/internals/GroupPlaybackTrack.d.ts.map +1 -1
  41. package/bin/internals/GroupPlaybackTrack.js +121 -121
  42. package/bin/internals/GroupPlaybackTrackData.d.ts +39 -39
  43. package/bin/internals/GroupPlaybackTrackData.d.ts.map +1 -1
  44. package/bin/internals/GroupPlaybackTrackData.js +69 -69
  45. package/bin/internals/GroupTransportState.d.ts +49 -48
  46. package/bin/internals/GroupTransportState.d.ts.map +1 -1
  47. package/bin/internals/GroupTransportState.js +111 -111
  48. package/bin/internals/GroupTransportState.js.map +1 -1
  49. package/bin/internals/consts.d.ts +75 -72
  50. package/bin/internals/consts.d.ts.map +1 -1
  51. package/bin/internals/consts.js +84 -81
  52. package/bin/internals/consts.js.map +1 -1
  53. package/bin/internals/index.d.ts +10 -10
  54. package/bin/internals/index.js +26 -26
  55. package/package.json +9 -7
  56. package/src/LiveMediaSession.ts +24 -20
  57. package/src/LiveMediaSessionCoordinator.ts +101 -29
  58. package/src/MediaPlayerSynchronizer.ts +30 -14
  59. package/src/internals/GroupCoordinatorState.ts +49 -34
  60. package/src/internals/GroupPlaybackPosition.ts +7 -3
  61. package/src/internals/GroupPlaybackTrack.ts +2 -2
  62. package/src/internals/GroupPlaybackTrackData.ts +2 -2
  63. package/src/internals/GroupTransportState.ts +11 -4
  64. package/src/internals/consts.ts +4 -0
  65. package/typedoc.json +10 -0
  66. package/bin/EphemeralMediaSession.d.ts +0 -102
  67. package/bin/EphemeralMediaSession.d.ts.map +0 -1
  68. package/bin/EphemeralMediaSession.js +0 -226
  69. package/bin/EphemeralMediaSession.js.map +0 -1
  70. package/bin/EphemeralMediaSessionCoordinator.d.ts +0 -228
  71. package/bin/EphemeralMediaSessionCoordinator.d.ts.map +0 -1
  72. package/bin/EphemeralMediaSessionCoordinator.js +0 -396
  73. package/bin/EphemeralMediaSessionCoordinator.js.map +0 -1
  74. package/bin/EphemeralMediaSessionCoordinatorSuspension.d.ts +0 -20
  75. package/bin/EphemeralMediaSessionCoordinatorSuspension.d.ts.map +0 -1
  76. package/bin/EphemeralMediaSessionCoordinatorSuspension.js +0 -28
  77. package/bin/EphemeralMediaSessionCoordinatorSuspension.js.map +0 -1
  78. package/bin/VolumeLimiter.d.ts +0 -70
  79. package/bin/VolumeLimiter.d.ts.map +0 -1
  80. package/bin/VolumeLimiter.js +0 -170
  81. package/bin/VolumeLimiter.js.map +0 -1
  82. package/src/test/GroupPlaybackPosition.spec.ts +0 -600
  83. package/src/test/GroupPlaybackTrack.spec.ts +0 -122
  84. package/src/test/SharedMediaSession.spec.ts +0 -149
  85. package/src/test/SharedMediaSessionCoordinator.spec.ts +0 -271
  86. package/src/test/VolumeManager.spec.ts +0 -219
@@ -1,232 +1,229 @@
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
- Object.defineProperty(exports, "__esModule", { value: true });
16
- exports.LiveMediaSession = void 0;
17
- const aqueduct_1 = require("@fluidframework/aqueduct");
18
- const live_share_1 = require("@microsoft/live-share");
19
- const MediaPlayerSynchronizer_1 = require("./MediaPlayerSynchronizer");
20
- const internals_1 = require("./internals");
21
- const MediaSessionExtensions_1 = require("./MediaSessionExtensions");
22
- const LiveMediaSessionCoordinator_1 = require("./LiveMediaSessionCoordinator");
23
- const RepeatedActionThrottler_1 = require("./RepeatedActionThrottler");
24
- /**
25
- * Live fluid object that synchronizes media playback across multiple clients.
26
- */
27
- class LiveMediaSession extends aqueduct_1.DataObject {
28
- constructor() {
29
- super(...arguments);
30
- this._actionThrottler = new RepeatedActionThrottler_1.RepeatedActionThrottler();
31
- this._actionHandlers = new Map();
32
- this._lastUpdateTime = 0;
33
- }
34
- /**
35
- * Extension point that lets applications replace the default logic for throttling the sessions
36
- * local sync behavior.
37
- *
38
- * @remarks
39
- * The `LiveMediaCoordinator` is fairly aggressive at wanting to keep the local media player
40
- * in sync with the rest of the group. This aggressiveness can result in the coordinator sending
41
- * new sync actions before the local player has finished responding to the previous sync action.
42
- * The `ActionThrottler` gives apps fine grain control over how aggressive they want sync to be.
43
- *
44
- * By default, a `RepeatedAction` throttler is used which prevents the same sync action from
45
- * being sent within an adjustable time period.
46
- */
47
- get actionThrottler() {
48
- return this._actionThrottler;
49
- }
50
- set actionThrottler(value) {
51
- this._actionThrottler = value;
52
- }
53
- /**
54
- * Returns true if the object has been initialized.
55
- */
56
- get isInitialized() {
57
- return this.coordinator.isInitialized;
58
- }
59
- /**
60
- * @deprecated isInitialized should be used instead
61
- * Returns true if the object has been initialized.
62
- */
63
- get isStarted() {
64
- return this.isInitialized;
65
- }
66
- /**
67
- * The group coordinator for the session.
68
- */
69
- get coordinator() {
70
- return this._coordinator;
71
- }
72
- /**
73
- * Returns the logger used by the session and coordinator.
74
- *
75
- * @remarks
76
- * This is used by the `MediaPlayerSynchronizer` to log events.
77
- */
78
- get logger() {
79
- return this._logger;
80
- }
81
- /**
82
- * initialize the object.
83
- * @param acceptTransportChangesFrom Optional. List of roles allowed to group transport
84
- * operations like play/pause/seek/setTrack.
85
- */
86
- initialize(acceptTransportChangesFrom) {
87
- return this.coordinator.initialize(acceptTransportChangesFrom);
88
- }
89
- /**
90
- * Registers an action handler with the session.
91
- * @param action Name of the action to register a handler for.
92
- * @param handler Function called when the action is triggered.
93
- */
94
- setActionHandler(action, handler) {
95
- if (handler) {
96
- // add handler
97
- this._actionHandlers.set(action, handler);
98
- }
99
- else if (this._actionHandlers.has(action)) {
100
- // remove handler
101
- this._actionHandlers.delete(action);
102
- }
103
- }
104
- /**
105
- * Registers a handler that will be queried anytime the group coordinate needs to know the
106
- * local players transport state and position.
107
- */
108
- setRequestPlayerStateHandler(handler) {
109
- this._requestPlayerStateHandler = handler;
110
- }
111
- /**
112
- * Begins synchronizing the playback of a media element.
113
- * @param player Something that "looks like" and HTML Media Element.
114
- * @returns A new synchronizer instance. Call `synchronizer.end()` to stop synchronizing the elements playback.
115
- */
116
- synchronize(player) {
117
- // A session can only synchronize one player at a time
118
- if (this._synchronizing) {
119
- this._synchronizing.end();
120
- }
121
- // Start position update timer
122
- if (!this._updateTimer) {
123
- this.logger.sendTelemetryEvent(internals_1.TelemetryEvents.MediaSession.BeginPositionUpdateTimer);
124
- this._updateTimer = setInterval(() => {
125
- // Get current state
126
- const state = this.getCurrentPlayerState();
127
- // Check for hit wait point
128
- this.checkWaitPointHit(state);
129
- // Send position update if interval hit
130
- const now = new Date().getTime();
131
- const delta = (now - this._lastUpdateTime) / 1000;
132
- if (this.coordinator.isInitialized &&
133
- delta >= this.coordinator.positionUpdateInterval) {
134
- this._lastUpdateTime = now;
135
- this.coordinator.sendPositionUpdate(state);
136
- }
137
- }, 500);
138
- }
139
- return new MediaPlayerSynchronizer_1.MediaPlayerSynchronizer(player, this, () => {
140
- this._synchronizing = undefined;
141
- });
142
- }
143
- hasInitialized() {
144
- return __awaiter(this, void 0, void 0, function* () {
145
- this._logger = new live_share_1.LiveTelemetryLogger(this.runtime);
146
- // Create coordinator and listen for triggered actions
147
- this._coordinator = new LiveMediaSessionCoordinator_1.LiveMediaSessionCoordinator(this.runtime, () => this.getCurrentPlayerState());
148
- this._coordinator.on(MediaSessionExtensions_1.MediaSessionCoordinatorEvents.triggeraction, (event) => {
149
- // Pre-process actions
150
- const details = event.details;
151
- const seekTime = typeof details.seekTime == "number" ? details.seekTime : -1;
152
- switch (details.action) {
153
- case "play":
154
- this.logger.sendTelemetryEvent(internals_1.TelemetryEvents.MediaSession.PlayAction, null, {
155
- position: seekTime,
156
- });
157
- break;
158
- case "pause":
159
- this.logger.sendTelemetryEvent(internals_1.TelemetryEvents.MediaSession.PauseAction, null, {
160
- position: seekTime,
161
- });
162
- break;
163
- case "seekto":
164
- this.logger.sendTelemetryEvent(internals_1.TelemetryEvents.MediaSession.SeekToAction, null, {
165
- position: seekTime,
166
- });
167
- break;
168
- case "settrack":
169
- this.logger.sendTelemetryEvent(internals_1.TelemetryEvents.MediaSession.SetTrackAction);
170
- break;
171
- case "datachange":
172
- this.logger.sendTelemetryEvent(internals_1.TelemetryEvents.MediaSession.DataChangeAction);
173
- break;
174
- case "catchup":
175
- // Default to seekto if catchup not implemented
176
- this.logger.sendTelemetryEvent(internals_1.TelemetryEvents.MediaSession.CatchUpAction, null, {
177
- position: seekTime,
178
- });
179
- if (!this._actionHandlers.has("catchup")) {
180
- details.action = "seekto";
181
- }
182
- break;
183
- }
184
- // Dispatch action
185
- this.dispatchAction(details);
186
- });
187
- });
188
- }
189
- checkWaitPointHit(state) {
190
- // Was a wait point hit?
191
- if (state.positionState && this.coordinator.isInitialized) {
192
- const waitPoint = this.coordinator.findNextWaitPoint();
193
- if (waitPoint &&
194
- state.positionState.position != undefined &&
195
- state.positionState.position >= waitPoint.position) {
196
- // Ensure handler registered
197
- if (!this._actionHandlers.has("wait")) {
198
- throw new Error(`SharedMediaSession: wait point hit but no 'wait' action registered.`);
199
- }
200
- // Begin suspension for wait point
201
- const suspension = this.coordinator.beginSuspension(waitPoint);
202
- this.dispatchAction({ action: "wait", suspension: suspension });
203
- }
204
- }
205
- }
206
- getCurrentPlayerState() {
207
- if (!this._requestPlayerStateHandler) {
208
- throw new Error(`SharedMediaSession: no getPlayerState callback configured.`);
209
- }
210
- return this._requestPlayerStateHandler();
211
- }
212
- dispatchAction(details) {
213
- if (this._actionHandlers.has(details.action)) {
214
- const handler = this._actionHandlers.get(details.action);
215
- this._actionThrottler.throttled(details, handler);
216
- }
217
- }
218
- }
219
- exports.LiveMediaSession = LiveMediaSession;
220
- /**
221
- * The objects fluid type name.
222
- */
223
- LiveMediaSession.TypeName = `@microsoft/fluid-media:SharedMediaSession`;
224
- /**
225
- * The objects fluid type factory.
226
- */
227
- LiveMediaSession.factory = new aqueduct_1.DataObjectFactory(LiveMediaSession.TypeName, LiveMediaSession, [], {});
228
- /**
229
- * Register `LiveMediaSession` as an available `LoadableObjectClass` for use in packages that support dynamic object loading, such as `@microsoft/live-share-turbo`.
230
- */
231
- live_share_1.DynamicObjectRegistry.registerObjectClass(LiveMediaSession, LiveMediaSession.TypeName);
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
+ Object.defineProperty(exports, "__esModule", { value: true });
16
+ exports.LiveMediaSession = void 0;
17
+ const aqueduct_1 = require("@fluidframework/aqueduct");
18
+ const live_share_1 = require("@microsoft/live-share");
19
+ const MediaPlayerSynchronizer_1 = require("./MediaPlayerSynchronizer");
20
+ const internals_1 = require("./internals");
21
+ const MediaSessionExtensions_1 = require("./MediaSessionExtensions");
22
+ const LiveMediaSessionCoordinator_1 = require("./LiveMediaSessionCoordinator");
23
+ const RepeatedActionThrottler_1 = require("./RepeatedActionThrottler");
24
+ /**
25
+ * Live fluid object that synchronizes media playback across multiple clients.
26
+ */
27
+ class LiveMediaSession extends live_share_1.LiveDataObject {
28
+ constructor() {
29
+ super(...arguments);
30
+ this._actionThrottler = new RepeatedActionThrottler_1.RepeatedActionThrottler();
31
+ this._actionHandlers = new Map();
32
+ this._lastUpdateTime = 0;
33
+ }
34
+ /**
35
+ * Extension point that lets applications replace the default logic for throttling the sessions
36
+ * local sync behavior.
37
+ *
38
+ * @remarks
39
+ * The `LiveMediaCoordinator` is fairly aggressive at wanting to keep the local media player
40
+ * in sync with the rest of the group. This aggressiveness can result in the coordinator sending
41
+ * new sync actions before the local player has finished responding to the previous sync action.
42
+ * The `ActionThrottler` gives apps fine grain control over how aggressive they want sync to be.
43
+ *
44
+ * By default, a `RepeatedAction` throttler is used which prevents the same sync action from
45
+ * being sent within an adjustable time period.
46
+ */
47
+ get actionThrottler() {
48
+ return this._actionThrottler;
49
+ }
50
+ set actionThrottler(value) {
51
+ this._actionThrottler = value;
52
+ }
53
+ /**
54
+ * Returns true if the object has been initialized.
55
+ */
56
+ get isInitialized() {
57
+ return this.coordinator.isInitialized;
58
+ }
59
+ /**
60
+ * The group coordinator for the session.
61
+ */
62
+ get coordinator() {
63
+ return this._coordinator;
64
+ }
65
+ /**
66
+ * Returns the logger used by the session and coordinator.
67
+ *
68
+ * @remarks
69
+ * This is used by the `MediaPlayerSynchronizer` to log events.
70
+ */
71
+ get logger() {
72
+ return this._logger;
73
+ }
74
+ /**
75
+ * initialize the object.
76
+ * @param allowedRoles Optional. List of roles allowed to group transport
77
+ * operations like play/pause/seek/setTrack.
78
+ * @returns a void promise that resolves once complete
79
+ */
80
+ initialize(allowedRoles) {
81
+ if (allowedRoles) {
82
+ this._allowedRoles = allowedRoles;
83
+ }
84
+ return this.coordinator.initialize(allowedRoles);
85
+ }
86
+ /**
87
+ * Registers an action handler with the session.
88
+ * @param action Name of the action to register a handler for.
89
+ * @param handler Function called when the action is triggered.
90
+ */
91
+ setActionHandler(action, handler) {
92
+ if (handler) {
93
+ // add handler
94
+ this._actionHandlers.set(action, handler);
95
+ }
96
+ else if (this._actionHandlers.has(action)) {
97
+ // remove handler
98
+ this._actionHandlers.delete(action);
99
+ }
100
+ }
101
+ /**
102
+ * Registers a handler that will be queried anytime the group coordinate needs to know the
103
+ * local players transport state and position.
104
+ */
105
+ setRequestPlayerStateHandler(handler) {
106
+ this._requestPlayerStateHandler = handler;
107
+ }
108
+ /**
109
+ * Begins synchronizing the playback of a media element.
110
+ * @param player Something that "looks like" and HTML Media Element.
111
+ * @returns A new synchronizer instance. Call `synchronizer.end()` to stop synchronizing the elements playback.
112
+ */
113
+ synchronize(player) {
114
+ // A session can only synchronize one player at a time
115
+ if (this._synchronizing) {
116
+ this._synchronizing.end();
117
+ }
118
+ // Start position update timer
119
+ if (!this._updateTimer) {
120
+ this.logger.sendTelemetryEvent(internals_1.TelemetryEvents.MediaSession.BeginPositionUpdateTimer);
121
+ this._updateTimer = setInterval(() => {
122
+ // Get current state
123
+ const state = this.getCurrentPlayerState();
124
+ // Check for hit wait point
125
+ this.checkWaitPointHit(state);
126
+ // Send position update if interval hit
127
+ const now = new Date().getTime();
128
+ const delta = (now - this._lastUpdateTime) / 1000;
129
+ if (this.coordinator.isInitialized &&
130
+ delta >= this.coordinator.positionUpdateInterval) {
131
+ this._lastUpdateTime = now;
132
+ this.coordinator.sendPositionUpdate(state);
133
+ }
134
+ }, 500);
135
+ }
136
+ return new MediaPlayerSynchronizer_1.MediaPlayerSynchronizer(player, this, () => {
137
+ this._synchronizing = undefined;
138
+ });
139
+ }
140
+ hasInitialized() {
141
+ return __awaiter(this, void 0, void 0, function* () {
142
+ this._logger = new live_share_1.LiveTelemetryLogger(this.runtime, this.liveRuntime);
143
+ // Create coordinator and listen for triggered actions
144
+ this._coordinator = new LiveMediaSessionCoordinator_1.LiveMediaSessionCoordinator(this.runtime, this.liveRuntime, () => this.getCurrentPlayerState());
145
+ this._coordinator.on(MediaSessionExtensions_1.MediaSessionCoordinatorEvents.triggeraction, (event) => {
146
+ // Pre-process actions
147
+ const details = event.details;
148
+ const seekTime = typeof details.seekTime == "number" ? details.seekTime : -1;
149
+ switch (details.action) {
150
+ case "play":
151
+ this.logger.sendTelemetryEvent(internals_1.TelemetryEvents.MediaSession.PlayAction, null, {
152
+ position: seekTime,
153
+ });
154
+ break;
155
+ case "pause":
156
+ this.logger.sendTelemetryEvent(internals_1.TelemetryEvents.MediaSession.PauseAction, null, {
157
+ position: seekTime,
158
+ });
159
+ break;
160
+ case "seekto":
161
+ this.logger.sendTelemetryEvent(internals_1.TelemetryEvents.MediaSession.SeekToAction, null, {
162
+ position: seekTime,
163
+ });
164
+ break;
165
+ case "settrack":
166
+ this.logger.sendTelemetryEvent(internals_1.TelemetryEvents.MediaSession.SetTrackAction);
167
+ break;
168
+ case "datachange":
169
+ this.logger.sendTelemetryEvent(internals_1.TelemetryEvents.MediaSession.DataChangeAction);
170
+ break;
171
+ case "catchup":
172
+ // Default to seekto if catchup not implemented
173
+ this.logger.sendTelemetryEvent(internals_1.TelemetryEvents.MediaSession.CatchUpAction, null, {
174
+ position: seekTime,
175
+ });
176
+ if (!this._actionHandlers.has("catchup")) {
177
+ details.action = "seekto";
178
+ }
179
+ break;
180
+ }
181
+ // Dispatch action
182
+ this.dispatchAction(details);
183
+ });
184
+ });
185
+ }
186
+ checkWaitPointHit(state) {
187
+ // Was a wait point hit?
188
+ if (state.positionState && this.coordinator.isInitialized) {
189
+ const waitPoint = this.coordinator.findNextWaitPoint();
190
+ if (waitPoint &&
191
+ state.positionState.position != undefined &&
192
+ state.positionState.position >= waitPoint.position) {
193
+ // Ensure handler registered
194
+ if (!this._actionHandlers.has("wait")) {
195
+ throw new Error(`SharedMediaSession: wait point hit but no 'wait' action registered.`);
196
+ }
197
+ // Begin suspension for wait point
198
+ const suspension = this.coordinator.beginSuspension(waitPoint);
199
+ this.dispatchAction({ action: "wait", suspension: suspension });
200
+ }
201
+ }
202
+ }
203
+ getCurrentPlayerState() {
204
+ if (!this._requestPlayerStateHandler) {
205
+ throw new Error(`SharedMediaSession: no getPlayerState callback configured.`);
206
+ }
207
+ return this._requestPlayerStateHandler();
208
+ }
209
+ dispatchAction(details) {
210
+ if (this._actionHandlers.has(details.action)) {
211
+ const handler = this._actionHandlers.get(details.action);
212
+ this._actionThrottler.throttled(details, handler);
213
+ }
214
+ }
215
+ }
216
+ /**
217
+ * The objects fluid type name.
218
+ */
219
+ LiveMediaSession.TypeName = `@microsoft/fluid-media:SharedMediaSession`;
220
+ /**
221
+ * The objects fluid type factory.
222
+ */
223
+ LiveMediaSession.factory = new aqueduct_1.DataObjectFactory(LiveMediaSession.TypeName, LiveMediaSession, [], {});
224
+ exports.LiveMediaSession = LiveMediaSession;
225
+ /**
226
+ * Register `LiveMediaSession` as an available `LoadableObjectClass` for use in packages that support dynamic object loading, such as `@microsoft/live-share-turbo`.
227
+ */
228
+ live_share_1.DynamicObjectRegistry.registerObjectClass(LiveMediaSession, LiveMediaSession.TypeName);
232
229
  //# sourceMappingURL=LiveMediaSession.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"LiveMediaSession.js","sourceRoot":"","sources":["../src/LiveMediaSession.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;;;;AAEH,uDAAyE;AACzE,sDAAoG;AACpG,uEAAoE;AACpE,2CAAmE;AACnE,qEAIkC;AAClC,+EAGuC;AAEvC,uEAAoE;AAGpE;;GAEG;AACH,MAAa,gBAAiB,SAAQ,qBAAU;IAAhD;;QACY,qBAAgB,GACpB,IAAI,iDAAuB,EAAE,CAAC;QAIjB,oBAAe,GAC5B,IAAI,GAAG,EAAE,CAAC;QAKN,oBAAe,GAAW,CAAC,CAAC;IAsQxC,CAAC;IArPG;;;;;;;;;;;;OAYG;IACH,IA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