@microsoft/live-share-media 2.0.0-internal.15 → 2.0.0-internal.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.
- package/bin/IMediaPlayer.d.ts +21 -0
- package/bin/IMediaPlayer.d.ts.map +1 -0
- package/bin/IMediaPlayer.js +7 -0
- package/bin/IMediaPlayer.js.map +1 -0
- package/bin/LiveMediaSession.d.ts +90 -0
- package/bin/LiveMediaSession.d.ts.map +1 -0
- package/bin/LiveMediaSession.js +255 -0
- package/bin/LiveMediaSession.js.map +1 -0
- package/bin/LiveMediaSessionCoordinator.d.ts +259 -0
- package/bin/LiveMediaSessionCoordinator.d.ts.map +1 -0
- package/bin/LiveMediaSessionCoordinator.js +472 -0
- package/bin/LiveMediaSessionCoordinator.js.map +1 -0
- package/bin/LiveMediaSessionCoordinatorSuspension.d.ts +20 -0
- package/bin/LiveMediaSessionCoordinatorSuspension.d.ts.map +1 -0
- package/bin/LiveMediaSessionCoordinatorSuspension.js +28 -0
- package/bin/LiveMediaSessionCoordinatorSuspension.js.map +1 -0
- package/bin/MediaPlayerSynchronizer.d.ts +189 -0
- package/bin/MediaPlayerSynchronizer.d.ts.map +1 -0
- package/bin/MediaPlayerSynchronizer.js +577 -0
- package/bin/MediaPlayerSynchronizer.js.map +1 -0
- package/bin/MediaSessionActionThrottler.d.ts +12 -0
- package/bin/MediaSessionActionThrottler.d.ts.map +1 -0
- package/bin/MediaSessionActionThrottler.js +14 -0
- package/bin/MediaSessionActionThrottler.js.map +1 -0
- package/bin/MediaSessionExtensions.d.ts +177 -0
- package/bin/MediaSessionExtensions.d.ts.map +1 -0
- package/bin/MediaSessionExtensions.js +26 -0
- package/bin/MediaSessionExtensions.js.map +1 -0
- package/bin/RepeatedActionThrottler.d.ts +20 -0
- package/bin/RepeatedActionThrottler.d.ts.map +1 -0
- package/bin/RepeatedActionThrottler.js +63 -0
- package/bin/RepeatedActionThrottler.js.map +1 -0
- package/bin/VolumeManager.d.ts +84 -0
- package/bin/VolumeManager.d.ts.map +1 -0
- package/bin/VolumeManager.js +175 -0
- package/bin/VolumeManager.js.map +1 -0
- package/bin/index.d.ts +14 -0
- package/bin/index.d.ts.map +1 -0
- package/bin/index.js +30 -0
- package/bin/index.js.map +1 -0
- package/bin/internals/GroupCoordinatorState.d.ts +107 -0
- package/bin/internals/GroupCoordinatorState.d.ts.map +1 -0
- package/bin/internals/GroupCoordinatorState.js +519 -0
- package/bin/internals/GroupCoordinatorState.js.map +1 -0
- package/bin/internals/GroupPlaybackPosition.d.ts +70 -0
- package/bin/internals/GroupPlaybackPosition.d.ts.map +1 -0
- package/bin/internals/GroupPlaybackPosition.js +170 -0
- package/bin/internals/GroupPlaybackPosition.js.map +1 -0
- package/bin/internals/GroupPlaybackRate.d.ts +38 -0
- package/bin/internals/GroupPlaybackRate.d.ts.map +1 -0
- package/bin/internals/GroupPlaybackRate.js +62 -0
- package/bin/internals/GroupPlaybackRate.js.map +1 -0
- package/bin/internals/GroupPlaybackTrack.d.ts +45 -0
- package/bin/internals/GroupPlaybackTrack.d.ts.map +1 -0
- package/bin/internals/GroupPlaybackTrack.js +125 -0
- package/bin/internals/GroupPlaybackTrack.js.map +1 -0
- package/bin/internals/GroupPlaybackTrackData.d.ts +40 -0
- package/bin/internals/GroupPlaybackTrackData.d.ts.map +1 -0
- package/bin/internals/GroupPlaybackTrackData.js +73 -0
- package/bin/internals/GroupPlaybackTrackData.js.map +1 -0
- package/bin/internals/GroupTransportState.d.ts +52 -0
- package/bin/internals/GroupTransportState.d.ts.map +1 -0
- package/bin/internals/GroupTransportState.js +123 -0
- package/bin/internals/GroupTransportState.js.map +1 -0
- package/bin/internals/consts.d.ts +83 -0
- package/bin/internals/consts.d.ts.map +1 -0
- package/bin/internals/consts.js +92 -0
- package/bin/internals/consts.js.map +1 -0
- package/bin/internals/errors.d.ts +17 -0
- package/bin/internals/errors.d.ts.map +1 -0
- package/bin/internals/errors.js +34 -0
- package/bin/internals/errors.js.map +1 -0
- package/bin/internals/index.d.ts +13 -0
- package/bin/internals/index.d.ts.map +1 -0
- package/bin/internals/index.js +29 -0
- package/bin/internals/index.js.map +1 -0
- package/bin/internals/interfaces.d.ts +10 -0
- package/bin/internals/interfaces.d.ts.map +1 -0
- package/bin/internals/interfaces.js +3 -0
- package/bin/internals/interfaces.js.map +1 -0
- package/package.json +7 -7
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
|
+
* Licensed under the Microsoft Live Share SDK License.
|
|
4
|
+
*/
|
|
5
|
+
export interface IMediaPlayer {
|
|
6
|
+
readonly currentSrc: string;
|
|
7
|
+
currentTime: number;
|
|
8
|
+
readonly duration: number;
|
|
9
|
+
readonly ended: boolean;
|
|
10
|
+
muted: boolean;
|
|
11
|
+
readonly paused: boolean;
|
|
12
|
+
playbackRate: number;
|
|
13
|
+
src: string;
|
|
14
|
+
volume: number;
|
|
15
|
+
load(): void;
|
|
16
|
+
pause(): void;
|
|
17
|
+
play(): Promise<void>;
|
|
18
|
+
addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void;
|
|
19
|
+
removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void;
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=IMediaPlayer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IMediaPlayer.d.ts","sourceRoot":"","sources":["../src/IMediaPlayer.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,WAAW,YAAY;IACzB,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;IACxB,KAAK,EAAE,OAAO,CAAC;IACf,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;IACzB,YAAY,EAAE,MAAM,CAAC;IACrB,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,IAAI,IAAI,CAAC;IACb,KAAK,IAAI,IAAI,CAAC;IACd,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACtB,gBAAgB,CACZ,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,kCAAkC,EAC5C,OAAO,CAAC,EAAE,OAAO,GAAG,uBAAuB,GAC5C,IAAI,CAAC;IACR,mBAAmB,CACf,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,kCAAkC,EAC5C,OAAO,CAAC,EAAE,OAAO,GAAG,oBAAoB,GACzC,IAAI,CAAC;CACX"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IMediaPlayer.js","sourceRoot":"","sources":["../src/IMediaPlayer.ts"],"names":[],"mappings":";AAAA;;;GAGG"}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
|
+
* Licensed under the Microsoft Live Share SDK License.
|
|
4
|
+
*/
|
|
5
|
+
import { DataObjectFactory } from "@fluidframework/aqueduct";
|
|
6
|
+
import { LiveDataObject, LiveTelemetryLogger, UserMeetingRole } from "@microsoft/live-share";
|
|
7
|
+
import { MediaPlayerSynchronizer } from "./MediaPlayerSynchronizer";
|
|
8
|
+
import { ExtendedMediaSessionAction, ExtendedMediaSessionActionHandler } from "./MediaSessionExtensions";
|
|
9
|
+
import { LiveMediaSessionCoordinator, IMediaPlayerState } from "./LiveMediaSessionCoordinator";
|
|
10
|
+
import { MediaSessionActionThrottler } from "./MediaSessionActionThrottler";
|
|
11
|
+
import { IMediaPlayer } from "./IMediaPlayer";
|
|
12
|
+
/**
|
|
13
|
+
* Live fluid object that synchronizes media playback across multiple clients.
|
|
14
|
+
*/
|
|
15
|
+
export declare class LiveMediaSession extends LiveDataObject {
|
|
16
|
+
private _actionThrottler;
|
|
17
|
+
private _logger?;
|
|
18
|
+
private _requestPlayerStateHandler?;
|
|
19
|
+
private _coordinator?;
|
|
20
|
+
private readonly _actionHandlers;
|
|
21
|
+
private _synchronizing?;
|
|
22
|
+
private _updateTimer;
|
|
23
|
+
private _lastUpdateTime;
|
|
24
|
+
/**
|
|
25
|
+
* The objects fluid type name.
|
|
26
|
+
*/
|
|
27
|
+
static readonly TypeName = "@microsoft/fluid-media:SharedMediaSession";
|
|
28
|
+
/**
|
|
29
|
+
* The objects fluid type factory.
|
|
30
|
+
*/
|
|
31
|
+
static readonly factory: DataObjectFactory<LiveMediaSession, import("@fluidframework/aqueduct").DataObjectTypes>;
|
|
32
|
+
/**
|
|
33
|
+
* Extension point that lets applications replace the default logic for throttling the sessions
|
|
34
|
+
* local sync behavior.
|
|
35
|
+
*
|
|
36
|
+
* @remarks
|
|
37
|
+
* The `LiveMediaCoordinator` is fairly aggressive at wanting to keep the local media player
|
|
38
|
+
* in sync with the rest of the group. This aggressiveness can result in the coordinator sending
|
|
39
|
+
* new sync actions before the local player has finished responding to the previous sync action.
|
|
40
|
+
* The `ActionThrottler` gives apps fine grain control over how aggressive they want sync to be.
|
|
41
|
+
*
|
|
42
|
+
* By default, a `RepeatedAction` throttler is used which prevents the same sync action from
|
|
43
|
+
* being sent within an adjustable time period.
|
|
44
|
+
*/
|
|
45
|
+
get actionThrottler(): MediaSessionActionThrottler;
|
|
46
|
+
set actionThrottler(value: MediaSessionActionThrottler);
|
|
47
|
+
/**
|
|
48
|
+
* The group coordinator for the session.
|
|
49
|
+
*/
|
|
50
|
+
get coordinator(): LiveMediaSessionCoordinator;
|
|
51
|
+
/**
|
|
52
|
+
* Returns the logger used by the session and coordinator.
|
|
53
|
+
*
|
|
54
|
+
* @remarks
|
|
55
|
+
* This is used by the `MediaPlayerSynchronizer` to log events.
|
|
56
|
+
*/
|
|
57
|
+
get logger(): LiveTelemetryLogger;
|
|
58
|
+
/**
|
|
59
|
+
* Initialize the object to begin sending/receiving group playback updates through this DDS.
|
|
60
|
+
*
|
|
61
|
+
* @param allowedRoles Optional. List of roles allowed to group transport operations like play/pause/seek/setTrack.
|
|
62
|
+
*
|
|
63
|
+
* @returns a void promise that resolves once complete.
|
|
64
|
+
*
|
|
65
|
+
* @throws error when `.initialize()` has already been called for this class instance.
|
|
66
|
+
*/
|
|
67
|
+
initialize(allowedRoles?: UserMeetingRole[]): Promise<void>;
|
|
68
|
+
/**
|
|
69
|
+
* Registers an action handler with the session.
|
|
70
|
+
* @param action Name of the action to register a handler for.
|
|
71
|
+
* @param handler Function called when the action is triggered.
|
|
72
|
+
*/
|
|
73
|
+
setActionHandler(action: ExtendedMediaSessionAction, handler: ExtendedMediaSessionActionHandler | MediaSessionActionHandler | null): void;
|
|
74
|
+
/**
|
|
75
|
+
* Registers a handler that will be queried anytime the group coordinate needs to know the
|
|
76
|
+
* local players transport state and position.
|
|
77
|
+
*/
|
|
78
|
+
setRequestPlayerStateHandler(handler: () => IMediaPlayerState): void;
|
|
79
|
+
/**
|
|
80
|
+
* Begins synchronizing the playback of a media element.
|
|
81
|
+
* @param player Something that "looks like" and HTML Media Element.
|
|
82
|
+
* @returns A new synchronizer instance. Call `synchronizer.end()` to stop synchronizing the elements playback.
|
|
83
|
+
*/
|
|
84
|
+
synchronize(player: IMediaPlayer): MediaPlayerSynchronizer;
|
|
85
|
+
protected hasInitialized(): Promise<void>;
|
|
86
|
+
private checkWaitPointHit;
|
|
87
|
+
private getCurrentPlayerState;
|
|
88
|
+
private dispatchAction;
|
|
89
|
+
}
|
|
90
|
+
//# sourceMappingURL=LiveMediaSession.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LiveMediaSession.d.ts","sourceRoot":"","sources":["../src/LiveMediaSession.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC7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;;;OAGG;IACI,4BAA4B,CAAC,OAAO,EAAE,MAAM,iBAAiB;IAIpE;;;;OAIG;IACI,WAAW,CAAC,MAAM,EAAE,YAAY,GAAG,uBAAuB;cAoCjD,cAAc,IAAI,OAAO,CAAC,IAAI,CAAC;IAwF/C,OAAO,CAAC,iBAAiB;IAgCzB,OAAO,CAAC,qBAAqB;IAU7B,OAAO,CAAC,cAAc;CAQzB"}
|
|
@@ -0,0 +1,255 @@
|
|
|
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
|
+
* The group coordinator for the session.
|
|
55
|
+
*/
|
|
56
|
+
get coordinator() {
|
|
57
|
+
return this._coordinator;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Returns the logger used by the session and coordinator.
|
|
61
|
+
*
|
|
62
|
+
* @remarks
|
|
63
|
+
* This is used by the `MediaPlayerSynchronizer` to log events.
|
|
64
|
+
*/
|
|
65
|
+
get logger() {
|
|
66
|
+
return this._logger;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Initialize the object to begin sending/receiving group playback updates through this DDS.
|
|
70
|
+
*
|
|
71
|
+
* @param allowedRoles Optional. List of roles allowed to group transport operations like play/pause/seek/setTrack.
|
|
72
|
+
*
|
|
73
|
+
* @returns a void promise that resolves once complete.
|
|
74
|
+
*
|
|
75
|
+
* @throws error when `.initialize()` has already been called for this class instance.
|
|
76
|
+
*/
|
|
77
|
+
initialize(allowedRoles) {
|
|
78
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
79
|
+
live_share_1.LiveDataObjectInitializeNotNeededError.assert("LiveMediaSession:initialize", this.initializeState);
|
|
80
|
+
// Update initialize state as pending
|
|
81
|
+
this.initializeState = live_share_1.LiveDataObjectInitializeState.pending;
|
|
82
|
+
if (allowedRoles) {
|
|
83
|
+
this._allowedRoles = allowedRoles;
|
|
84
|
+
}
|
|
85
|
+
try {
|
|
86
|
+
yield this.coordinator.initialize(allowedRoles);
|
|
87
|
+
}
|
|
88
|
+
catch (error) {
|
|
89
|
+
this.initializeState = live_share_1.LiveDataObjectInitializeState.needed;
|
|
90
|
+
throw error;
|
|
91
|
+
}
|
|
92
|
+
// Update initialize state as succeeded
|
|
93
|
+
this.initializeState = live_share_1.LiveDataObjectInitializeState.succeeded;
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Registers an action handler with the session.
|
|
98
|
+
* @param action Name of the action to register a handler for.
|
|
99
|
+
* @param handler Function called when the action is triggered.
|
|
100
|
+
*/
|
|
101
|
+
setActionHandler(action, handler) {
|
|
102
|
+
if (handler) {
|
|
103
|
+
// add handler
|
|
104
|
+
this._actionHandlers.set(action, handler);
|
|
105
|
+
}
|
|
106
|
+
else if (this._actionHandlers.has(action)) {
|
|
107
|
+
// remove handler
|
|
108
|
+
this._actionHandlers.delete(action);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Registers a handler that will be queried anytime the group coordinate needs to know the
|
|
113
|
+
* local players transport state and position.
|
|
114
|
+
*/
|
|
115
|
+
setRequestPlayerStateHandler(handler) {
|
|
116
|
+
this._requestPlayerStateHandler = handler;
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Begins synchronizing the playback of a media element.
|
|
120
|
+
* @param player Something that "looks like" and HTML Media Element.
|
|
121
|
+
* @returns A new synchronizer instance. Call `synchronizer.end()` to stop synchronizing the elements playback.
|
|
122
|
+
*/
|
|
123
|
+
synchronize(player) {
|
|
124
|
+
// A session can only synchronize one player at a time
|
|
125
|
+
if (this._synchronizing) {
|
|
126
|
+
this._synchronizing.end();
|
|
127
|
+
}
|
|
128
|
+
// Start position update timer
|
|
129
|
+
if (!this._updateTimer) {
|
|
130
|
+
this.logger.sendTelemetryEvent(internals_1.TelemetryEvents.MediaSession.BeginPositionUpdateTimer);
|
|
131
|
+
this._updateTimer = setInterval(() => {
|
|
132
|
+
// Get current state
|
|
133
|
+
const state = this.getCurrentPlayerState();
|
|
134
|
+
// Check for hit wait point
|
|
135
|
+
this.checkWaitPointHit(state);
|
|
136
|
+
// Send position update if interval hit
|
|
137
|
+
const now = new Date().getTime();
|
|
138
|
+
const delta = (now - this._lastUpdateTime) / 1000;
|
|
139
|
+
if (this.coordinator.isInitialized &&
|
|
140
|
+
delta >= this.coordinator.positionUpdateInterval) {
|
|
141
|
+
this._lastUpdateTime = now;
|
|
142
|
+
this.coordinator.sendPositionUpdate(state);
|
|
143
|
+
}
|
|
144
|
+
}, 500);
|
|
145
|
+
}
|
|
146
|
+
return new MediaPlayerSynchronizer_1.MediaPlayerSynchronizer(player, this, this.runtime, () => {
|
|
147
|
+
this._synchronizing = undefined;
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
hasInitialized() {
|
|
151
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
152
|
+
this._logger = new live_share_1.LiveTelemetryLogger(this.runtime, this.liveRuntime);
|
|
153
|
+
// Create coordinator and listen for triggered actions
|
|
154
|
+
this._coordinator = new LiveMediaSessionCoordinator_1.LiveMediaSessionCoordinator(this.id, this.runtime, this.liveRuntime, () => this.getCurrentPlayerState());
|
|
155
|
+
this._coordinator.on(MediaSessionExtensions_1.MediaSessionCoordinatorEvents.triggeraction, (event) => {
|
|
156
|
+
// Pre-process actions
|
|
157
|
+
const details = event.details;
|
|
158
|
+
const seekTime = typeof details.seekTime == "number" ? details.seekTime : -1;
|
|
159
|
+
switch (details.action) {
|
|
160
|
+
case "play":
|
|
161
|
+
this.logger.sendTelemetryEvent(internals_1.TelemetryEvents.MediaSession.PlayAction, null, {
|
|
162
|
+
position: seekTime,
|
|
163
|
+
});
|
|
164
|
+
break;
|
|
165
|
+
case "pause":
|
|
166
|
+
this.logger.sendTelemetryEvent(internals_1.TelemetryEvents.MediaSession.PauseAction, null, {
|
|
167
|
+
position: seekTime,
|
|
168
|
+
});
|
|
169
|
+
break;
|
|
170
|
+
case "ratechange":
|
|
171
|
+
if (!details.playbackRate) {
|
|
172
|
+
break;
|
|
173
|
+
}
|
|
174
|
+
this.logger.sendTelemetryEvent(internals_1.TelemetryEvents.MediaSession.RateChangeAction, null, {
|
|
175
|
+
playbackRate: details.playbackRate,
|
|
176
|
+
});
|
|
177
|
+
break;
|
|
178
|
+
case "seekto":
|
|
179
|
+
this.logger.sendTelemetryEvent(internals_1.TelemetryEvents.MediaSession.SeekToAction, null, {
|
|
180
|
+
position: seekTime,
|
|
181
|
+
});
|
|
182
|
+
break;
|
|
183
|
+
case "settrack":
|
|
184
|
+
this.logger.sendTelemetryEvent(internals_1.TelemetryEvents.MediaSession.SetTrackAction);
|
|
185
|
+
break;
|
|
186
|
+
case "datachange":
|
|
187
|
+
this.logger.sendTelemetryEvent(internals_1.TelemetryEvents.MediaSession.DataChangeAction);
|
|
188
|
+
break;
|
|
189
|
+
case "catchup":
|
|
190
|
+
// Default to seekto if catchup not implemented
|
|
191
|
+
this.logger.sendTelemetryEvent(internals_1.TelemetryEvents.MediaSession.CatchUpAction, null, {
|
|
192
|
+
position: seekTime,
|
|
193
|
+
});
|
|
194
|
+
if (!this._actionHandlers.has("catchup")) {
|
|
195
|
+
details.action = "seekto";
|
|
196
|
+
}
|
|
197
|
+
break;
|
|
198
|
+
}
|
|
199
|
+
// Dispatch action
|
|
200
|
+
this.dispatchAction(details);
|
|
201
|
+
});
|
|
202
|
+
});
|
|
203
|
+
}
|
|
204
|
+
checkWaitPointHit(state) {
|
|
205
|
+
// Was a wait point hit?
|
|
206
|
+
if (state.positionState && this.coordinator.isInitialized) {
|
|
207
|
+
const waitPoint = this.coordinator.findNextWaitPoint();
|
|
208
|
+
if (waitPoint &&
|
|
209
|
+
state.positionState.position != undefined &&
|
|
210
|
+
state.positionState.position >= waitPoint.position) {
|
|
211
|
+
// Ensure handler registered
|
|
212
|
+
if (!this._actionHandlers.has("wait")) {
|
|
213
|
+
throw new Error(`LiveMediaSession:checkWaitPointHit - wait point hit but no 'wait' action registered.\nTo fix this error, set a \`wait\` action using the \`setActionHandler()\` function.`);
|
|
214
|
+
}
|
|
215
|
+
// Begin suspension for wait point
|
|
216
|
+
this.waitUntilConnected().then((clientId) => {
|
|
217
|
+
const suspension = this.coordinator.beginSuspension(waitPoint);
|
|
218
|
+
this.dispatchAction({
|
|
219
|
+
action: "wait",
|
|
220
|
+
source: "system",
|
|
221
|
+
clientId,
|
|
222
|
+
local: true,
|
|
223
|
+
suspension,
|
|
224
|
+
});
|
|
225
|
+
});
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
getCurrentPlayerState() {
|
|
230
|
+
if (!this._requestPlayerStateHandler) {
|
|
231
|
+
throw new Error("LiveMediaSession:getCurrentPlayerState - no `requestPlayerStateHandler` callback configured.\nTo fix this error, ensure `setRequestPlayerStateHandler()` has been set with a delegate to retrieve your player's state, or use the `synchronize()` function to create a new `MediaPlayerSynchronizer` instance tied to your `IMediaPlayer` instance.");
|
|
232
|
+
}
|
|
233
|
+
return this._requestPlayerStateHandler();
|
|
234
|
+
}
|
|
235
|
+
dispatchAction(details) {
|
|
236
|
+
if (this._actionHandlers.has(details.action)) {
|
|
237
|
+
const handler = this._actionHandlers.get(details.action);
|
|
238
|
+
this._actionThrottler.throttled(details, handler);
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
/**
|
|
243
|
+
* The objects fluid type name.
|
|
244
|
+
*/
|
|
245
|
+
LiveMediaSession.TypeName = `@microsoft/fluid-media:SharedMediaSession`;
|
|
246
|
+
/**
|
|
247
|
+
* The objects fluid type factory.
|
|
248
|
+
*/
|
|
249
|
+
LiveMediaSession.factory = new aqueduct_1.DataObjectFactory(LiveMediaSession.TypeName, LiveMediaSession, [], {});
|
|
250
|
+
exports.LiveMediaSession = LiveMediaSession;
|
|
251
|
+
/**
|
|
252
|
+
* Register `LiveMediaSession` as an available `LoadableObjectClass` for use in packages that support dynamic object loading, such as `@microsoft/live-share-turbo`.
|
|
253
|
+
*/
|
|
254
|
+
live_share_1.DynamicObjectRegistry.registerObjectClass(LiveMediaSession, LiveMediaSession.TypeName);
|
|
255
|
+
//# sourceMappingURL=LiveMediaSession.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LiveMediaSession.js","sourceRoot":"","sources":["../src/LiveMediaSession.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;;;;AAEH,uDAA6D;AAC7D,sDAO+B;AAC/B,uEAAoE;AACpE,2CAAmE;AACnE,qEAKkC;AAClC,+EAGuC;AAEvC,uEAAoE;AAGpE;;GAEG;AACH,MAAa,gBAAiB,SAAQ,2BAAc;IAApD;;QACY,qBAAgB,GACpB,IAAI,iDAAuB,EAAE,CAAC;QAIjB,oBAAe,GAG5B,IAAI,GAAG,EAAE,CAAC;QAKN,oBAAe,GAAW,CAAC,CAAC;IAqSxC,CAAC;IApRG;;;;;;;;;;;;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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I,CAAC,cAAc,CAAC;wBAChB,MAAM,EAAE,MAAM;wBACd,MAAM,EAAE,QAAQ;wBAChB,QAAQ;wBACR,KAAK,EAAE,IAAI;wBACX,UAAU;qBACb,CAAC,CAAC;gBACP,CAAC,CAAC,CAAC;aACN;SACJ;IACL,CAAC;IAEO,qBAAqB;QACzB,IAAI,CAAC,IAAI,CAAC,0BAA0B,EAAE;YAClC,MAAM,IAAI,KAAK,CACX,qVAAqV,CACxV,CAAC;SACL;QAED,OAAO,IAAI,CAAC,0BAA0B,EAAE,CAAC;IAC7C,CAAC;IAEO,cAAc,CAClB,OAAsE;QAEtE,IAAI,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE;YAC1C,MAAM,OAAO,GAAG,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;YACzD,IAAI,CAAC,gBAAgB,CAAC,SAAS,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;SACrD;IACL,CAAC;;AAlSD;;GAEG;AACoB,yBAAQ,GAAG,2CAA2C,AAA9C,CAA+C;AAE9E;;GAEG;AACoB,wBAAO,GAAG,IAAI,4BAAiB,CAClD,gBAAgB,CAAC,QAAQ,EACzB,gBAAgB,EAChB,EAAE,EACF,EAAE,CACL,AAL6B,CAK5B;AA7BO,4CAAgB;AAqT7B;;GAEG;AACH,kCAAqB,CAAC,mBAAmB,CACrC,gBAAgB,EAChB,gBAAgB,CAAC,QAAQ,CAC5B,CAAC"}
|
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
|
+
* Licensed under the Microsoft Live Share SDK License.
|
|
4
|
+
*/
|
|
5
|
+
import { IRuntimeSignaler, UserMeetingRole, LiveShareRuntime } from "@microsoft/live-share";
|
|
6
|
+
import { CoordinationWaitPoint, ExtendedMediaMetadata, ExtendedMediaSessionPlaybackState, MediaSessionCoordinatorSuspension } from "./MediaSessionExtensions";
|
|
7
|
+
import EventEmitter from "events";
|
|
8
|
+
/**
|
|
9
|
+
* Most recent state of the media session.
|
|
10
|
+
*/
|
|
11
|
+
export interface IMediaPlayerState {
|
|
12
|
+
/**
|
|
13
|
+
* Metadata for the sessions current track.
|
|
14
|
+
*/
|
|
15
|
+
metadata: ExtendedMediaMetadata | null;
|
|
16
|
+
/**
|
|
17
|
+
* Optional track data object being synchronized.
|
|
18
|
+
*
|
|
19
|
+
* @remarks
|
|
20
|
+
* This can be used to sync things like pitch, roll, and yaw when watching 360 videos together.
|
|
21
|
+
*/
|
|
22
|
+
trackData: object | null;
|
|
23
|
+
/**
|
|
24
|
+
* Sessions current playback state.
|
|
25
|
+
*/
|
|
26
|
+
playbackState: ExtendedMediaSessionPlaybackState;
|
|
27
|
+
/**
|
|
28
|
+
* Sessions current position state if known.
|
|
29
|
+
*/
|
|
30
|
+
positionState?: MediaPositionState;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* The `LiveMediaSessionCoordinator` tracks the playback & position state of all other
|
|
34
|
+
* clients being synchronized with. It is responsible for keeping the local media player
|
|
35
|
+
* in sync with the group.
|
|
36
|
+
*/
|
|
37
|
+
export declare class LiveMediaSessionCoordinator extends EventEmitter {
|
|
38
|
+
private readonly _id;
|
|
39
|
+
private readonly _runtime;
|
|
40
|
+
private readonly _liveRuntime;
|
|
41
|
+
private readonly _logger;
|
|
42
|
+
private readonly _getPlayerState;
|
|
43
|
+
private _positionUpdateInterval;
|
|
44
|
+
private _maxPlaybackDrift;
|
|
45
|
+
private _lastWaitPoint?;
|
|
46
|
+
private initializeState;
|
|
47
|
+
private _playEvent?;
|
|
48
|
+
private _pauseEvent?;
|
|
49
|
+
private _seekToEvent?;
|
|
50
|
+
private _rateChangeEvent?;
|
|
51
|
+
private _setTrackEvent?;
|
|
52
|
+
private _setTrackDataEvent?;
|
|
53
|
+
private _positionUpdateEvent?;
|
|
54
|
+
private _synchronizer?;
|
|
55
|
+
private _groupState?;
|
|
56
|
+
/**
|
|
57
|
+
* @hidden
|
|
58
|
+
* Applications shouldn't directly create new coordinator instances.
|
|
59
|
+
*/
|
|
60
|
+
constructor(id: string, runtime: IRuntimeSignaler, liveRuntime: LiveShareRuntime, getPlayerState: () => IMediaPlayerState);
|
|
61
|
+
/**
|
|
62
|
+
* Controls whether or not the local client is allowed to instruct the group to play or pause.
|
|
63
|
+
*
|
|
64
|
+
* @remarks
|
|
65
|
+
* This flag largely meant to influence decisions made by the coordinator and can be used by
|
|
66
|
+
* the UI to determine what controls should be shown to the user. It does not provide any
|
|
67
|
+
* security in itself.
|
|
68
|
+
*
|
|
69
|
+
* If your app is running in a semi-trusted environment where only some clients are allowed
|
|
70
|
+
* to play/pause media, you should use "role based verification" to enforce those policies.
|
|
71
|
+
*/
|
|
72
|
+
canPlayPause: boolean;
|
|
73
|
+
/**
|
|
74
|
+
* Controls whether or not the local client is allowed to seek the group to a new playback
|
|
75
|
+
* position.
|
|
76
|
+
*
|
|
77
|
+
* @remarks
|
|
78
|
+
* This flag largely meant to influence decisions made by the coordinator and can be used by
|
|
79
|
+
* the UI to determine what controls should be shown to the user. It does not provide any
|
|
80
|
+
* security in itself.
|
|
81
|
+
*
|
|
82
|
+
* If your app is running in a semi-trusted environment where only some clients are allowed
|
|
83
|
+
* to change the playback position, you should use "role based verification" to enforce those policies.
|
|
84
|
+
*/
|
|
85
|
+
canSeek: boolean;
|
|
86
|
+
/**
|
|
87
|
+
* Controls whether or not the local client is allowed to change tracks.
|
|
88
|
+
*
|
|
89
|
+
* @remarks
|
|
90
|
+
* This flag largely meant to influence decisions made by the coordinator and can be used by
|
|
91
|
+
* the UI to determine what controls should be shown to the user. It does not provide any
|
|
92
|
+
* security in itself.
|
|
93
|
+
*
|
|
94
|
+
* If your app is running in a semi-trusted environment where only some clients are allowed
|
|
95
|
+
* to change tracks, you should use "role based verification" to enforce those policies.
|
|
96
|
+
*/
|
|
97
|
+
canSetTrack: boolean;
|
|
98
|
+
/**
|
|
99
|
+
* Controls whether or not the local client is allowed to change the tracks custom data object.
|
|
100
|
+
*
|
|
101
|
+
* @remarks
|
|
102
|
+
* This flag largely meant to influence decisions made by the coordinator and can be used by
|
|
103
|
+
* the UI to determine what controls should be shown to the user. It does not provide any
|
|
104
|
+
* security in itself.
|
|
105
|
+
*
|
|
106
|
+
* If your app is running in a semi-trusted environment where only some clients are allowed
|
|
107
|
+
* to change the tracks data object, you should use "role based verification" to enforce those
|
|
108
|
+
* policies.
|
|
109
|
+
*/
|
|
110
|
+
canSetTrackData: boolean;
|
|
111
|
+
/**
|
|
112
|
+
* Controls whether or not the local client is allowed to change the playback rate.
|
|
113
|
+
*
|
|
114
|
+
* @remarks
|
|
115
|
+
* This flag largely meant to influence decisions made by the coordinator and can be used by
|
|
116
|
+
* the UI to determine what controls should be shown to the user. It does not provide any
|
|
117
|
+
* security in itself.
|
|
118
|
+
*
|
|
119
|
+
* If your app is running in a semi-trusted environment where only some clients are allowed
|
|
120
|
+
* to change the tracks data object, you should use "role based verification" to enforce those
|
|
121
|
+
* policies.
|
|
122
|
+
*/
|
|
123
|
+
canSetPlaybackRate: boolean;
|
|
124
|
+
/**
|
|
125
|
+
* Controls whether or not the local client is allowed to send position updates to the group.
|
|
126
|
+
*
|
|
127
|
+
* @remarks
|
|
128
|
+
* This flag largely meant to limit the number of signals sent to the group for performance reasons.
|
|
129
|
+
* It does not provide any security in itself.
|
|
130
|
+
*/
|
|
131
|
+
canSendPositionUpdates: boolean;
|
|
132
|
+
/**
|
|
133
|
+
* Returns true if the local client is in a suspended state.
|
|
134
|
+
*/
|
|
135
|
+
get isSuspended(): boolean;
|
|
136
|
+
/**
|
|
137
|
+
* Max amount of playback drift allowed in seconds.
|
|
138
|
+
*
|
|
139
|
+
* @remarks
|
|
140
|
+
* Should the local clients playback position lag by more than the specified value, the
|
|
141
|
+
* coordinator will trigger a `catchup` action.
|
|
142
|
+
*
|
|
143
|
+
* Defaults to a value of `1` second.
|
|
144
|
+
*/
|
|
145
|
+
get maxPlaybackDrift(): number;
|
|
146
|
+
set maxPlaybackDrift(value: number);
|
|
147
|
+
/**
|
|
148
|
+
* Frequency with which position updates are broadcast to the rest of the group in
|
|
149
|
+
* seconds.
|
|
150
|
+
*
|
|
151
|
+
* @remarks
|
|
152
|
+
* Defaults to a value of `2` seconds.
|
|
153
|
+
*/
|
|
154
|
+
get positionUpdateInterval(): number;
|
|
155
|
+
set positionUpdateInterval(value: number);
|
|
156
|
+
/**
|
|
157
|
+
* Instructs the group to play the current track.
|
|
158
|
+
*
|
|
159
|
+
* @remarks
|
|
160
|
+
* Throws an exception if the session/coordinator hasn't been initialized, no track has been
|
|
161
|
+
* loaded, or `canPlayPause` is false.
|
|
162
|
+
*
|
|
163
|
+
* @returns a void promise that resolves once complete, throws if user does not have proper roles
|
|
164
|
+
*/
|
|
165
|
+
play(): Promise<void>;
|
|
166
|
+
/**
|
|
167
|
+
* Instructs the group to pause the current track.
|
|
168
|
+
*
|
|
169
|
+
* @remarks
|
|
170
|
+
* Throws an exception if the session/coordinator hasn't been initialized, no track has been
|
|
171
|
+
* loaded, or `canPlayPause` is false.
|
|
172
|
+
*
|
|
173
|
+
* @returns a void promise that resolves once complete, throws if user does not have proper roles
|
|
174
|
+
*/
|
|
175
|
+
pause(): Promise<void>;
|
|
176
|
+
/**
|
|
177
|
+
* Instructs the group to seek to a new position within the current track.
|
|
178
|
+
*
|
|
179
|
+
* @remarks
|
|
180
|
+
* Throws an exception if the session/coordinator hasn't been initialized, no track has been
|
|
181
|
+
* loaded, or `canSeek` is false.
|
|
182
|
+
* @param time Playback position in seconds to seek to.
|
|
183
|
+
* @returns a void promise that resolves once complete, throws if user does not have proper roles
|
|
184
|
+
*/
|
|
185
|
+
seekTo(time: number): Promise<void>;
|
|
186
|
+
setPlaybackRate(playbackRate: number): Promise<void>;
|
|
187
|
+
/**
|
|
188
|
+
* Instructs the group to load a new track.
|
|
189
|
+
*
|
|
190
|
+
* @remarks
|
|
191
|
+
* Throws an exception if the session/coordinator hasn't been initialized or `canSetTrack` is
|
|
192
|
+
* false.
|
|
193
|
+
* @param metadata The track to load or `null` to indicate that the end of the track is reached.
|
|
194
|
+
* @param waitPoints Optional. List of static wait points to configure for the track. Dynamic wait points can be added via the `beginSuspension()` call.
|
|
195
|
+
* @returns a void promise that resolves once complete, throws if user does not have proper roles
|
|
196
|
+
*/
|
|
197
|
+
setTrack(metadata: ExtendedMediaMetadata | null, waitPoints?: CoordinationWaitPoint[]): Promise<void>;
|
|
198
|
+
/**
|
|
199
|
+
* Updates the track data object for the current track.
|
|
200
|
+
*
|
|
201
|
+
* @remarks
|
|
202
|
+
* The track data object can be used by applications to synchronize things like pitch, roll,
|
|
203
|
+
* and yaw of a 360 video. This data object will be reset to null anytime the track changes.
|
|
204
|
+
*
|
|
205
|
+
* Throws an exception if the session/coordinator hasn't been initialized or `canSetTrackData` is
|
|
206
|
+
* false.
|
|
207
|
+
* @param data New data object to sync with the group. This value will be synchronized using a last writer wins strategy.
|
|
208
|
+
* @returns a void promise that resolves once complete, throws if user does not have proper roles
|
|
209
|
+
*/
|
|
210
|
+
setTrackData(data: object | null): Promise<void>;
|
|
211
|
+
/**
|
|
212
|
+
* Begins a new local suspension.
|
|
213
|
+
*
|
|
214
|
+
* @remarks
|
|
215
|
+
* Suspension temporarily suspend the clients local synchronization with the group. This can
|
|
216
|
+
* be useful for displaying ads to users or temporarily disconnecting from the session while
|
|
217
|
+
* the user seeks the video using a timeline scrubber.
|
|
218
|
+
*
|
|
219
|
+
* Multiple simultaneous suspensions are allowed and when the last suspension ends the local
|
|
220
|
+
* client will be immediately re-synchronized with the group.
|
|
221
|
+
*
|
|
222
|
+
* A "Dynamic Wait Point" can be specified when `beginSuspension()` is called and the wait
|
|
223
|
+
* point will be broadcast to all other clients in the group. Those clients will then
|
|
224
|
+
* automatically enter a suspension state once they reach the positions specified by the
|
|
225
|
+
* wait point. Clients that are passed the wait point will immediately suspend.
|
|
226
|
+
*
|
|
227
|
+
* Any wait point based suspension (dynamic or static) will result in all clients remaining
|
|
228
|
+
* in a suspension state until the list client ends their suspension. This behavior can be
|
|
229
|
+
* conditionally bypassed by settings the wait points `maxClients` value.
|
|
230
|
+
*
|
|
231
|
+
* Throws an exception if the session/coordinator hasn't been initialized.
|
|
232
|
+
* @param waitPoint Optional. Dynamic wait point to broadcast to all of the clients.
|
|
233
|
+
* @returns The suspension object. Call `end()` on the returned suspension to end the suspension.
|
|
234
|
+
*/
|
|
235
|
+
beginSuspension(waitPoint?: CoordinationWaitPoint): MediaSessionCoordinatorSuspension;
|
|
236
|
+
/**
|
|
237
|
+
* @hidden
|
|
238
|
+
* Called by MediaSession to verify the coordinator has been initialized.
|
|
239
|
+
*/
|
|
240
|
+
get isInitialized(): boolean;
|
|
241
|
+
/**
|
|
242
|
+
* @hidden
|
|
243
|
+
* Called by MediaSession to start coordinator.
|
|
244
|
+
*/
|
|
245
|
+
initialize(acceptTransportChangesFrom?: UserMeetingRole[]): Promise<void>;
|
|
246
|
+
/**
|
|
247
|
+
* @hidden
|
|
248
|
+
* Called by the MediaSession to detect if a wait point has been hit.
|
|
249
|
+
*/
|
|
250
|
+
findNextWaitPoint(): CoordinationWaitPoint | null;
|
|
251
|
+
/**
|
|
252
|
+
* @hidden
|
|
253
|
+
* Called by MediaSession to trigger the sending of a position update.
|
|
254
|
+
*/
|
|
255
|
+
sendPositionUpdate(state: IMediaPlayerState): void;
|
|
256
|
+
protected createChildren(acceptTransportChangesFrom?: UserMeetingRole[]): Promise<void>;
|
|
257
|
+
private getPlayerPosition;
|
|
258
|
+
}
|
|
259
|
+
//# sourceMappingURL=LiveMediaSessionCoordinator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LiveMediaSessionCoordinator.d.ts","sourceRoot":"","sources":["../src/LiveMediaSessionCoordinator.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAIH,gBAAgB,EAEhB,eAAe,EACf,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