@microsoft/live-share-media 1.0.0-preview.9 → 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.
- package/LICENSE +64 -61
- package/README.md +7 -13
- package/bin/IMediaPlayer.d.ts +20 -20
- package/bin/IMediaPlayer.js +6 -6
- package/bin/LiveMediaSession.d.ts +90 -94
- package/bin/LiveMediaSession.d.ts.map +1 -1
- package/bin/LiveMediaSession.js +228 -231
- package/bin/LiveMediaSession.js.map +1 -1
- package/bin/LiveMediaSessionCoordinator.d.ts +238 -227
- package/bin/LiveMediaSessionCoordinator.d.ts.map +1 -1
- package/bin/LiveMediaSessionCoordinator.js +476 -407
- package/bin/LiveMediaSessionCoordinator.js.map +1 -1
- package/bin/LiveMediaSessionCoordinatorSuspension.d.ts +19 -19
- package/bin/LiveMediaSessionCoordinatorSuspension.js +27 -27
- package/bin/MediaPlayerSynchronizer.d.ts +173 -163
- package/bin/MediaPlayerSynchronizer.d.ts.map +1 -1
- package/bin/MediaPlayerSynchronizer.js +491 -468
- package/bin/MediaPlayerSynchronizer.js.map +1 -1
- package/bin/MediaSessionActionThrottler.d.ts +11 -11
- package/bin/MediaSessionActionThrottler.js +13 -13
- package/bin/MediaSessionExtensions.d.ts +34 -34
- package/bin/MediaSessionExtensions.d.ts.map +1 -1
- package/bin/MediaSessionExtensions.js +12 -12
- package/bin/RepeatedActionThrottler.d.ts +19 -19
- package/bin/RepeatedActionThrottler.js +62 -62
- package/bin/RepeatedActionThrottler.js.map +1 -1
- package/bin/VolumeManager.d.ts +83 -83
- package/bin/VolumeManager.js +174 -174
- package/bin/index.d.ts +13 -13
- package/bin/index.js +29 -29
- package/bin/internals/GroupCoordinatorState.d.ts +93 -92
- package/bin/internals/GroupCoordinatorState.d.ts.map +1 -1
- package/bin/internals/GroupCoordinatorState.js +407 -404
- package/bin/internals/GroupCoordinatorState.js.map +1 -1
- package/bin/internals/GroupPlaybackPosition.d.ts +67 -66
- package/bin/internals/GroupPlaybackPosition.d.ts.map +1 -1
- package/bin/internals/GroupPlaybackPosition.js +166 -166
- package/bin/internals/GroupPlaybackPosition.js.map +1 -1
- package/bin/internals/GroupPlaybackTrack.d.ts +45 -45
- package/bin/internals/GroupPlaybackTrack.d.ts.map +1 -1
- package/bin/internals/GroupPlaybackTrack.js +121 -121
- package/bin/internals/GroupPlaybackTrackData.d.ts +39 -39
- package/bin/internals/GroupPlaybackTrackData.d.ts.map +1 -1
- package/bin/internals/GroupPlaybackTrackData.js +69 -69
- package/bin/internals/GroupTransportState.d.ts +49 -48
- package/bin/internals/GroupTransportState.d.ts.map +1 -1
- package/bin/internals/GroupTransportState.js +111 -111
- package/bin/internals/GroupTransportState.js.map +1 -1
- package/bin/internals/consts.d.ts +75 -72
- package/bin/internals/consts.d.ts.map +1 -1
- package/bin/internals/consts.js +84 -81
- package/bin/internals/consts.js.map +1 -1
- package/bin/internals/index.d.ts +10 -10
- package/bin/internals/index.js +26 -26
- package/package.json +9 -7
- package/src/LiveMediaSession.ts +24 -20
- package/src/LiveMediaSessionCoordinator.ts +101 -29
- package/src/MediaPlayerSynchronizer.ts +30 -14
- package/src/internals/GroupCoordinatorState.ts +49 -34
- package/src/internals/GroupPlaybackPosition.ts +7 -3
- package/src/internals/GroupPlaybackTrack.ts +2 -2
- package/src/internals/GroupPlaybackTrackData.ts +2 -2
- package/src/internals/GroupTransportState.ts +11 -4
- package/src/internals/consts.ts +4 -0
- package/typedoc.json +10 -0
- package/bin/EphemeralMediaSession.d.ts +0 -102
- package/bin/EphemeralMediaSession.d.ts.map +0 -1
- package/bin/EphemeralMediaSession.js +0 -226
- package/bin/EphemeralMediaSession.js.map +0 -1
- package/bin/EphemeralMediaSessionCoordinator.d.ts +0 -228
- package/bin/EphemeralMediaSessionCoordinator.d.ts.map +0 -1
- package/bin/EphemeralMediaSessionCoordinator.js +0 -396
- package/bin/EphemeralMediaSessionCoordinator.js.map +0 -1
- package/bin/EphemeralMediaSessionCoordinatorSuspension.d.ts +0 -20
- package/bin/EphemeralMediaSessionCoordinatorSuspension.d.ts.map +0 -1
- package/bin/EphemeralMediaSessionCoordinatorSuspension.js +0 -28
- package/bin/EphemeralMediaSessionCoordinatorSuspension.js.map +0 -1
- package/bin/VolumeLimiter.d.ts +0 -70
- package/bin/VolumeLimiter.d.ts.map +0 -1
- package/bin/VolumeLimiter.js +0 -170
- package/bin/VolumeLimiter.js.map +0 -1
- package/src/test/GroupPlaybackPosition.spec.ts +0 -600
- package/src/test/GroupPlaybackTrack.spec.ts +0 -122
- package/src/test/SharedMediaSession.spec.ts +0 -149
- package/src/test/SharedMediaSessionCoordinator.spec.ts +0 -271
- package/src/test/VolumeManager.spec.ts +0 -219
package/bin/LiveMediaSession.js
CHANGED
|
@@ -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
|
|
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
|
-
*
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
*
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
*
|
|
76
|
-
*
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
this.
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
this.
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
break;
|
|
168
|
-
case "
|
|
169
|
-
this.logger.sendTelemetryEvent(internals_1.TelemetryEvents.MediaSession.
|
|
170
|
-
break;
|
|
171
|
-
case "
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
this.
|
|
177
|
-
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
/**
|
|
221
|
-
* The objects fluid type
|
|
222
|
-
*/
|
|
223
|
-
LiveMediaSession.
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
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,
|
|
1
|
+
{"version":3,"file":"LiveMediaSession.js","sourceRoot":"","sources":["../src/LiveMediaSession.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;;;;AAEH,uDAA6D;AAC7D,sDAK+B;AAC/B,uEAAoE;AACpE,2CAAmE;AACnE,qEAIkC;AAClC,+EAGuC;AAEvC,uEAAoE;AAGpE;;GAEG;AACH,MAAa,gBAAiB,SAAQ,2BAAc;IAApD;;QACY,qBAAgB,GACpB,IAAI,iDAAuB,EAAE,CAAC;QAIjB,oBAAe,GAC5B,IAAI,GAAG,EAAE,CAAC;QAKN,oBAAe,GAAW,CAAC,CAAC;IAkQxC,CAAC;IAjPG;;;;;;;;;;;;OAYG;IACH,IAAW,eAAe;QACtB,OAAO,IAAI,CAAC,gBAAgB,CAAC;IACjC,CAAC;IAED,IAAW,eAAe,CAAC,KAAkC;QACzD,IAAI,CAAC,gBAAgB,GAAG,KAAK,CAAC;IAClC,CAAC;IAED;;OAEG;IACH,IAAW,aAAa;QACpB,OAAO,IAAI,CAAC,WAAW,CAAC,aAAa,CAAC;IAC1C,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