@microsoft/live-share-media 2.0.0-internal.1 → 2.0.0-internal.10

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 (228) hide show
  1. package/README.md +30 -31
  2. package/bin/cjs/IMediaPlayer.d.ts.map +1 -0
  3. package/bin/cjs/IMediaPlayer.js.map +1 -0
  4. package/bin/{LiveMediaSession.d.ts → cjs/LiveMediaSession.d.ts} +16 -9
  5. package/bin/cjs/LiveMediaSession.d.ts.map +1 -0
  6. package/bin/{LiveMediaSession.js → cjs/LiveMediaSession.js} +31 -25
  7. package/bin/cjs/LiveMediaSession.js.map +1 -0
  8. package/bin/{LiveMediaSessionCoordinator.d.ts → cjs/LiveMediaSessionCoordinator.d.ts} +57 -13
  9. package/bin/cjs/LiveMediaSessionCoordinator.d.ts.map +1 -0
  10. package/bin/{LiveMediaSessionCoordinator.js → cjs/LiveMediaSessionCoordinator.js} +152 -64
  11. package/bin/cjs/LiveMediaSessionCoordinator.js.map +1 -0
  12. package/bin/{LiveMediaSessionCoordinatorSuspension.d.ts → cjs/LiveMediaSessionCoordinatorSuspension.d.ts} +1 -1
  13. package/bin/cjs/LiveMediaSessionCoordinatorSuspension.d.ts.map +1 -0
  14. package/bin/cjs/LiveMediaSessionCoordinatorSuspension.js.map +1 -0
  15. package/bin/{MediaPlayerSynchronizer.d.ts → cjs/MediaPlayerSynchronizer.d.ts} +22 -8
  16. package/bin/cjs/MediaPlayerSynchronizer.d.ts.map +1 -0
  17. package/bin/{MediaPlayerSynchronizer.js → cjs/MediaPlayerSynchronizer.js} +38 -41
  18. package/bin/cjs/MediaPlayerSynchronizer.js.map +1 -0
  19. package/bin/{MediaSessionActionThrottler.d.ts → cjs/MediaSessionActionThrottler.d.ts} +1 -1
  20. package/bin/cjs/MediaSessionActionThrottler.d.ts.map +1 -0
  21. package/bin/cjs/MediaSessionActionThrottler.js.map +1 -0
  22. package/bin/cjs/MediaSessionExtensions.d.ts.map +1 -0
  23. package/bin/cjs/MediaSessionExtensions.js.map +1 -0
  24. package/bin/{RepeatedActionThrottler.d.ts → cjs/RepeatedActionThrottler.d.ts} +2 -2
  25. package/bin/cjs/RepeatedActionThrottler.d.ts.map +1 -0
  26. package/bin/{RepeatedActionThrottler.js → cjs/RepeatedActionThrottler.js} +2 -2
  27. package/bin/cjs/RepeatedActionThrottler.js.map +1 -0
  28. package/bin/{VolumeManager.d.ts → cjs/VolumeManager.d.ts} +6 -6
  29. package/bin/cjs/VolumeManager.d.ts.map +1 -0
  30. package/bin/{VolumeManager.js → cjs/VolumeManager.js} +5 -5
  31. package/bin/cjs/VolumeManager.js.map +1 -0
  32. package/bin/cjs/index.d.ts +14 -0
  33. package/bin/cjs/index.d.ts.map +1 -0
  34. package/bin/{internals → cjs}/index.js +9 -8
  35. package/bin/cjs/index.js.map +1 -0
  36. package/bin/{internals → cjs/internals}/GroupCoordinatorState.d.ts +14 -12
  37. package/bin/cjs/internals/GroupCoordinatorState.d.ts.map +1 -0
  38. package/bin/{internals → cjs/internals}/GroupCoordinatorState.js +46 -49
  39. package/bin/cjs/internals/GroupCoordinatorState.js.map +1 -0
  40. package/bin/{internals → cjs/internals}/GroupPlaybackPosition.d.ts +6 -5
  41. package/bin/cjs/internals/GroupPlaybackPosition.d.ts.map +1 -0
  42. package/bin/{internals → cjs/internals}/GroupPlaybackPosition.js +3 -3
  43. package/bin/cjs/internals/GroupPlaybackPosition.js.map +1 -0
  44. package/bin/{internals → cjs/internals}/GroupPlaybackRate.d.ts +4 -5
  45. package/bin/cjs/internals/GroupPlaybackRate.d.ts.map +1 -0
  46. package/bin/{internals → cjs/internals}/GroupPlaybackRate.js +2 -5
  47. package/bin/cjs/internals/GroupPlaybackRate.js.map +1 -0
  48. package/bin/{internals → cjs/internals}/GroupPlaybackTrack.d.ts +5 -6
  49. package/bin/cjs/internals/GroupPlaybackTrack.d.ts.map +1 -0
  50. package/bin/{internals → cjs/internals}/GroupPlaybackTrack.js +2 -5
  51. package/bin/cjs/internals/GroupPlaybackTrack.js.map +1 -0
  52. package/bin/{internals → cjs/internals}/GroupPlaybackTrackData.d.ts +5 -6
  53. package/bin/cjs/internals/GroupPlaybackTrackData.d.ts.map +1 -0
  54. package/bin/{internals → cjs/internals}/GroupPlaybackTrackData.js +4 -7
  55. package/bin/cjs/internals/GroupPlaybackTrackData.js.map +1 -0
  56. package/bin/{internals → cjs/internals}/GroupTransportState.d.ts +8 -9
  57. package/bin/cjs/internals/GroupTransportState.d.ts.map +1 -0
  58. package/bin/{internals → cjs/internals}/GroupTransportState.js +4 -7
  59. package/bin/cjs/internals/GroupTransportState.js.map +1 -0
  60. package/bin/cjs/internals/PriorityTimeInterval.d.ts +33 -0
  61. package/bin/cjs/internals/PriorityTimeInterval.d.ts.map +1 -0
  62. package/bin/cjs/internals/PriorityTimeInterval.js +45 -0
  63. package/bin/cjs/internals/PriorityTimeInterval.js.map +1 -0
  64. package/bin/cjs/internals/consts.d.ts.map +1 -0
  65. package/bin/cjs/internals/consts.js.map +1 -0
  66. package/bin/cjs/internals/errors.d.ts.map +1 -0
  67. package/bin/cjs/internals/errors.js.map +1 -0
  68. package/bin/cjs/internals/interfaces.d.ts +23 -0
  69. package/bin/cjs/internals/interfaces.d.ts.map +1 -0
  70. package/bin/{internals → cjs/internals}/interfaces.js.map +1 -1
  71. package/bin/cjs/package.json +1 -0
  72. package/bin/esm/IMediaPlayer.d.ts +21 -0
  73. package/bin/esm/IMediaPlayer.d.ts.map +1 -0
  74. package/bin/esm/IMediaPlayer.js +6 -0
  75. package/bin/esm/IMediaPlayer.js.map +1 -0
  76. package/bin/esm/LiveMediaSession.d.ts +97 -0
  77. package/bin/esm/LiveMediaSession.d.ts.map +1 -0
  78. package/bin/esm/LiveMediaSession.js +257 -0
  79. package/bin/esm/LiveMediaSession.js.map +1 -0
  80. package/bin/esm/LiveMediaSessionCoordinator.d.ts +304 -0
  81. package/bin/esm/LiveMediaSessionCoordinator.d.ts.map +1 -0
  82. package/bin/esm/LiveMediaSessionCoordinator.js +556 -0
  83. package/bin/esm/LiveMediaSessionCoordinator.js.map +1 -0
  84. package/bin/esm/LiveMediaSessionCoordinatorSuspension.d.ts +20 -0
  85. package/bin/esm/LiveMediaSessionCoordinatorSuspension.d.ts.map +1 -0
  86. package/bin/esm/LiveMediaSessionCoordinatorSuspension.js +24 -0
  87. package/bin/esm/LiveMediaSessionCoordinatorSuspension.js.map +1 -0
  88. package/bin/esm/MediaPlayerSynchronizer.d.ts +204 -0
  89. package/bin/esm/MediaPlayerSynchronizer.d.ts.map +1 -0
  90. package/bin/esm/MediaPlayerSynchronizer.js +570 -0
  91. package/bin/esm/MediaPlayerSynchronizer.js.map +1 -0
  92. package/bin/esm/MediaSessionActionThrottler.d.ts +12 -0
  93. package/bin/esm/MediaSessionActionThrottler.d.ts.map +1 -0
  94. package/bin/esm/MediaSessionActionThrottler.js +10 -0
  95. package/bin/esm/MediaSessionActionThrottler.js.map +1 -0
  96. package/bin/esm/MediaSessionExtensions.d.ts +177 -0
  97. package/bin/esm/MediaSessionExtensions.d.ts.map +1 -0
  98. package/bin/esm/MediaSessionExtensions.js +23 -0
  99. package/bin/esm/MediaSessionExtensions.js.map +1 -0
  100. package/bin/esm/RepeatedActionThrottler.d.ts +20 -0
  101. package/bin/esm/RepeatedActionThrottler.d.ts.map +1 -0
  102. package/bin/esm/RepeatedActionThrottler.js +59 -0
  103. package/bin/esm/RepeatedActionThrottler.js.map +1 -0
  104. package/bin/esm/VolumeManager.d.ts +84 -0
  105. package/bin/esm/VolumeManager.d.ts.map +1 -0
  106. package/bin/esm/VolumeManager.js +171 -0
  107. package/bin/esm/VolumeManager.js.map +1 -0
  108. package/bin/esm/index.d.ts +14 -0
  109. package/bin/esm/index.d.ts.map +1 -0
  110. package/bin/esm/index.js +14 -0
  111. package/bin/esm/index.js.map +1 -0
  112. package/bin/esm/internals/GroupCoordinatorState.d.ts +110 -0
  113. package/bin/esm/internals/GroupCoordinatorState.d.ts.map +1 -0
  114. package/bin/esm/internals/GroupCoordinatorState.js +512 -0
  115. package/bin/esm/internals/GroupCoordinatorState.js.map +1 -0
  116. package/bin/esm/internals/GroupPlaybackPosition.d.ts +71 -0
  117. package/bin/esm/internals/GroupPlaybackPosition.d.ts.map +1 -0
  118. package/bin/esm/internals/GroupPlaybackPosition.js +166 -0
  119. package/bin/esm/internals/GroupPlaybackPosition.js.map +1 -0
  120. package/bin/esm/internals/GroupPlaybackRate.d.ts +38 -0
  121. package/bin/esm/internals/GroupPlaybackRate.d.ts.map +1 -0
  122. package/bin/esm/internals/GroupPlaybackRate.js +55 -0
  123. package/bin/esm/internals/GroupPlaybackRate.js.map +1 -0
  124. package/bin/esm/internals/GroupPlaybackTrack.d.ts +45 -0
  125. package/bin/esm/internals/GroupPlaybackTrack.d.ts.map +1 -0
  126. package/bin/esm/internals/GroupPlaybackTrack.js +118 -0
  127. package/bin/esm/internals/GroupPlaybackTrack.js.map +1 -0
  128. package/bin/esm/internals/GroupPlaybackTrackData.d.ts +40 -0
  129. package/bin/esm/internals/GroupPlaybackTrackData.d.ts.map +1 -0
  130. package/bin/esm/internals/GroupPlaybackTrackData.js +66 -0
  131. package/bin/esm/internals/GroupPlaybackTrackData.js.map +1 -0
  132. package/bin/esm/internals/GroupTransportState.d.ts +52 -0
  133. package/bin/esm/internals/GroupTransportState.d.ts.map +1 -0
  134. package/bin/esm/internals/GroupTransportState.js +116 -0
  135. package/bin/esm/internals/GroupTransportState.js.map +1 -0
  136. package/bin/esm/internals/PriorityTimeInterval.d.ts +33 -0
  137. package/bin/esm/internals/PriorityTimeInterval.d.ts.map +1 -0
  138. package/bin/esm/internals/PriorityTimeInterval.js +41 -0
  139. package/bin/esm/internals/PriorityTimeInterval.js.map +1 -0
  140. package/bin/esm/internals/consts.d.ts +83 -0
  141. package/bin/esm/internals/consts.d.ts.map +1 -0
  142. package/bin/esm/internals/consts.js +89 -0
  143. package/bin/esm/internals/consts.js.map +1 -0
  144. package/bin/esm/internals/errors.d.ts +17 -0
  145. package/bin/esm/internals/errors.d.ts.map +1 -0
  146. package/bin/esm/internals/errors.js +29 -0
  147. package/bin/esm/internals/errors.js.map +1 -0
  148. package/bin/esm/internals/interfaces.d.ts +23 -0
  149. package/bin/esm/internals/interfaces.d.ts.map +1 -0
  150. package/bin/esm/internals/interfaces.js +2 -0
  151. package/bin/esm/internals/interfaces.js.map +1 -0
  152. package/package.json +31 -12
  153. package/src/LiveMediaSession.ts +29 -14
  154. package/src/LiveMediaSessionCoordinator.ts +149 -37
  155. package/src/LiveMediaSessionCoordinatorSuspension.ts +1 -1
  156. package/src/MediaPlayerSynchronizer.ts +26 -11
  157. package/src/MediaSessionActionThrottler.ts +1 -1
  158. package/src/RepeatedActionThrottler.ts +2 -2
  159. package/src/VolumeManager.ts +6 -6
  160. package/src/index.ts +9 -9
  161. package/src/internals/GroupCoordinatorState.ts +19 -15
  162. package/src/internals/GroupPlaybackPosition.ts +9 -9
  163. package/src/internals/GroupPlaybackRate.ts +4 -4
  164. package/src/internals/GroupPlaybackTrack.ts +5 -5
  165. package/src/internals/GroupPlaybackTrackData.ts +5 -5
  166. package/src/internals/GroupTransportState.ts +8 -8
  167. package/src/internals/PriorityTimeInterval.ts +76 -0
  168. package/src/internals/interfaces.ts +15 -1
  169. package/tsconfig.cjs.json +14 -0
  170. package/tsconfig.json +65 -74
  171. package/.nycrc.json +0 -11
  172. package/bin/IMediaPlayer.d.ts.map +0 -1
  173. package/bin/IMediaPlayer.js.map +0 -1
  174. package/bin/LiveMediaSession.d.ts.map +0 -1
  175. package/bin/LiveMediaSession.js.map +0 -1
  176. package/bin/LiveMediaSessionCoordinator.d.ts.map +0 -1
  177. package/bin/LiveMediaSessionCoordinator.js.map +0 -1
  178. package/bin/LiveMediaSessionCoordinatorSuspension.d.ts.map +0 -1
  179. package/bin/LiveMediaSessionCoordinatorSuspension.js.map +0 -1
  180. package/bin/MediaPlayerSynchronizer.d.ts.map +0 -1
  181. package/bin/MediaPlayerSynchronizer.js.map +0 -1
  182. package/bin/MediaSessionActionThrottler.d.ts.map +0 -1
  183. package/bin/MediaSessionActionThrottler.js.map +0 -1
  184. package/bin/MediaSessionExtensions.d.ts.map +0 -1
  185. package/bin/MediaSessionExtensions.js.map +0 -1
  186. package/bin/RepeatedActionThrottler.d.ts.map +0 -1
  187. package/bin/RepeatedActionThrottler.js.map +0 -1
  188. package/bin/VolumeManager.d.ts.map +0 -1
  189. package/bin/VolumeManager.js.map +0 -1
  190. package/bin/index.d.ts +0 -14
  191. package/bin/index.d.ts.map +0 -1
  192. package/bin/index.js +0 -30
  193. package/bin/index.js.map +0 -1
  194. package/bin/internals/GroupCoordinatorState.d.ts.map +0 -1
  195. package/bin/internals/GroupCoordinatorState.js.map +0 -1
  196. package/bin/internals/GroupPlaybackPosition.d.ts.map +0 -1
  197. package/bin/internals/GroupPlaybackPosition.js.map +0 -1
  198. package/bin/internals/GroupPlaybackRate.d.ts.map +0 -1
  199. package/bin/internals/GroupPlaybackRate.js.map +0 -1
  200. package/bin/internals/GroupPlaybackTrack.d.ts.map +0 -1
  201. package/bin/internals/GroupPlaybackTrack.js.map +0 -1
  202. package/bin/internals/GroupPlaybackTrackData.d.ts.map +0 -1
  203. package/bin/internals/GroupPlaybackTrackData.js.map +0 -1
  204. package/bin/internals/GroupTransportState.d.ts.map +0 -1
  205. package/bin/internals/GroupTransportState.js.map +0 -1
  206. package/bin/internals/consts.d.ts.map +0 -1
  207. package/bin/internals/consts.js.map +0 -1
  208. package/bin/internals/errors.d.ts.map +0 -1
  209. package/bin/internals/errors.js.map +0 -1
  210. package/bin/internals/index.d.ts +0 -13
  211. package/bin/internals/index.d.ts.map +0 -1
  212. package/bin/internals/index.js.map +0 -1
  213. package/bin/internals/interfaces.d.ts +0 -10
  214. package/bin/internals/interfaces.d.ts.map +0 -1
  215. package/src/internals/index.ts +0 -13
  216. package/tsconfig.build.json +0 -9
  217. package/typedoc.json +0 -10
  218. /package/bin/{IMediaPlayer.d.ts → cjs/IMediaPlayer.d.ts} +0 -0
  219. /package/bin/{IMediaPlayer.js → cjs/IMediaPlayer.js} +0 -0
  220. /package/bin/{LiveMediaSessionCoordinatorSuspension.js → cjs/LiveMediaSessionCoordinatorSuspension.js} +0 -0
  221. /package/bin/{MediaSessionActionThrottler.js → cjs/MediaSessionActionThrottler.js} +0 -0
  222. /package/bin/{MediaSessionExtensions.d.ts → cjs/MediaSessionExtensions.d.ts} +0 -0
  223. /package/bin/{MediaSessionExtensions.js → cjs/MediaSessionExtensions.js} +0 -0
  224. /package/bin/{internals → cjs/internals}/consts.d.ts +0 -0
  225. /package/bin/{internals → cjs/internals}/consts.js +0 -0
  226. /package/bin/{internals → cjs/internals}/errors.d.ts +0 -0
  227. /package/bin/{internals → cjs/internals}/errors.js +0 -0
  228. /package/bin/{internals → cjs/internals}/interfaces.js +0 -0
@@ -3,35 +3,39 @@
3
3
  * Licensed under the Microsoft Live Share SDK License.
4
4
  */
5
5
 
6
- import { DataObjectFactory } from "@fluidframework/aqueduct";
6
+ import { DataObjectFactory } from "@fluidframework/aqueduct/legacy";
7
7
  import {
8
- DynamicObjectRegistry,
9
- LiveDataObject,
10
8
  LiveDataObjectInitializeNotNeededError,
11
9
  LiveDataObjectInitializeState,
12
10
  LiveTelemetryLogger,
13
11
  UserMeetingRole,
14
12
  } from "@microsoft/live-share";
15
- import { MediaPlayerSynchronizer } from "./MediaPlayerSynchronizer";
16
- import { ITriggerActionEvent, TelemetryEvents } from "./internals";
13
+ import {
14
+ DynamicObjectRegistry,
15
+ LiveDataObject,
16
+ } from "@microsoft/live-share/internal";
17
+ import { MediaPlayerSynchronizer } from "./MediaPlayerSynchronizer.js";
18
+ import { ITriggerActionEvent } from "./internals/GroupCoordinatorState.js";
17
19
  import {
18
20
  MediaSessionCoordinatorEvents,
19
21
  ExtendedMediaSessionAction,
20
22
  ExtendedMediaSessionActionDetails,
21
23
  ExtendedMediaSessionActionHandler,
22
- } from "./MediaSessionExtensions";
24
+ } from "./MediaSessionExtensions.js";
23
25
  import {
24
26
  LiveMediaSessionCoordinator,
25
27
  IMediaPlayerState,
26
- } from "./LiveMediaSessionCoordinator";
27
- import { MediaSessionActionThrottler } from "./MediaSessionActionThrottler";
28
- import { RepeatedActionThrottler } from "./RepeatedActionThrottler";
29
- import { IMediaPlayer } from "./IMediaPlayer";
28
+ } from "./LiveMediaSessionCoordinator.js";
29
+ import { MediaSessionActionThrottler } from "./MediaSessionActionThrottler.js";
30
+ import { RepeatedActionThrottler } from "./RepeatedActionThrottler.js";
31
+ import { IMediaPlayer } from "./IMediaPlayer.js";
32
+ import { SharedObjectKind } from "fluid-framework";
33
+ import { TelemetryEvents } from "./internals/consts.js";
30
34
 
31
35
  /**
32
36
  * Live fluid object that synchronizes media playback across multiple clients.
33
37
  */
34
- export class LiveMediaSession extends LiveDataObject {
38
+ export class LiveMediaSessionClass extends LiveDataObject {
35
39
  private _actionThrottler: MediaSessionActionThrottler =
36
40
  new RepeatedActionThrottler();
37
41
  private _logger?: LiveTelemetryLogger;
@@ -56,8 +60,8 @@ export class LiveMediaSession extends LiveDataObject {
56
60
  * The objects fluid type factory.
57
61
  */
58
62
  public static readonly factory = new DataObjectFactory(
59
- LiveMediaSession.TypeName,
60
- LiveMediaSession,
63
+ LiveMediaSessionClass.TypeName,
64
+ LiveMediaSessionClass,
61
65
  [],
62
66
  {}
63
67
  );
@@ -341,7 +345,18 @@ export class LiveMediaSession extends LiveDataObject {
341
345
  }
342
346
 
343
347
  /**
344
- * Register `LiveMediaSession` as an available `LoadableObjectClass` for use in packages that support dynamic object loading, such as `@microsoft/live-share-turbo`.
348
+ * Live fluid object that synchronizes media playback across multiple clients.
349
+ */
350
+ export type LiveMediaSession = LiveMediaSessionClass;
351
+
352
+ // eslint-disable-next-line no-redeclare
353
+ export const LiveMediaSession = (() => {
354
+ const kind = LiveMediaSessionClass;
355
+ return kind as typeof kind & SharedObjectKind<LiveMediaSessionClass>;
356
+ })();
357
+
358
+ /**
359
+ * Register `LiveMediaSession` as an available `SharedObjectKind` for use in dynamic object loading.
345
360
  */
346
361
  DynamicObjectRegistry.registerObjectClass(
347
362
  LiveMediaSession,
@@ -4,40 +4,46 @@
4
4
  */
5
5
 
6
6
  import {
7
- LiveEventScope,
8
7
  LiveTelemetryLogger,
9
- LiveEventTarget,
10
- IRuntimeSignaler,
11
8
  TimeInterval,
12
9
  UserMeetingRole,
13
- LiveShareRuntime,
14
10
  LiveDataObjectInitializeState,
15
11
  LiveDataObjectInitializeNotNeededError,
16
12
  LiveDataObjectNotInitializedError,
17
- LiveObjectSynchronizer,
18
13
  ILiveEvent,
19
14
  } from "@microsoft/live-share";
15
+ import {
16
+ IRuntimeSignaler,
17
+ LiveEventScope,
18
+ LiveEventTarget,
19
+ LiveObjectSynchronizer,
20
+ LiveShareRuntime,
21
+ isErrorLike,
22
+ } from "@microsoft/live-share/internal";
20
23
  import {
21
24
  CoordinationWaitPoint,
22
25
  ExtendedMediaMetadata,
23
26
  ExtendedMediaSessionPlaybackState,
24
27
  MediaSessionCoordinatorSuspension,
25
- } from "./MediaSessionExtensions";
28
+ } from "./MediaSessionExtensions.js";
26
29
  import {
27
- TelemetryEvents,
28
30
  ITransportCommandEvent,
29
31
  ISetTrackEvent,
30
32
  IPositionUpdateEvent,
31
33
  GroupCoordinatorState,
32
34
  GroupCoordinatorStateEvents,
33
35
  ISetTrackDataEvent,
36
+ IRateChangeCommandEvent,
37
+ } from "./internals/GroupCoordinatorState.js";
38
+ import { TelemetryEvents } from "./internals/consts.js";
39
+ import {
34
40
  TrackMetadataNotSetError,
35
41
  ActionBlockedError,
36
- IRateChangeCommandEvent,
37
- } from "./internals";
38
- import { LiveMediaSessionCoordinatorSuspension } from "./LiveMediaSessionCoordinatorSuspension";
39
- import EventEmitter from "events";
40
- import { isErrorLike } from "@microsoft/live-share/bin/internals";
42
+ } from "./internals/errors.js";
43
+ import { PriorityTimeInterval } from "./internals/PriorityTimeInterval.js";
44
+ import { LiveMediaSessionCoordinatorSuspension } from "./LiveMediaSessionCoordinatorSuspension.js";
45
+ import { TypedEventEmitter } from "@fluid-internal/client-utils";
46
+ import { IEvent } from "@fluidframework/core-interfaces";
41
47
 
42
48
  /**
43
49
  * Most recent state of the media session.
@@ -67,19 +73,51 @@ export interface IMediaPlayerState {
67
73
  positionState?: MediaPositionState;
68
74
  }
69
75
 
76
+ /**
77
+ * @hidden
78
+ */
79
+ export interface ILiveMediaSessionCoordinatorEvents extends IEvent {
80
+ /**
81
+ * Event listener for events emitted
82
+ * @param event update
83
+ * @param listener listener function
84
+ * @param listener.event the event instance
85
+ */
86
+ (event: string, listener: (event: any) => void): void;
87
+ }
88
+
70
89
  /**
71
90
  * The `LiveMediaSessionCoordinator` tracks the playback & position state of all other
72
91
  * clients being synchronized with. It is responsible for keeping the local media player
73
92
  * in sync with the group.
74
93
  */
75
- export class LiveMediaSessionCoordinator extends EventEmitter {
94
+ export class LiveMediaSessionCoordinator extends TypedEventEmitter<ILiveMediaSessionCoordinatorEvents> {
76
95
  private readonly _id: string;
77
96
  private readonly _runtime: IRuntimeSignaler;
78
97
  private readonly _liveRuntime: LiveShareRuntime;
79
98
  private readonly _logger: LiveTelemetryLogger;
80
99
  private readonly _getPlayerState: () => IMediaPlayerState;
81
- private _positionUpdateInterval = new TimeInterval(2000);
82
- private _maxPlaybackDrift = new TimeInterval(1000);
100
+ private _positionUpdateInterval = new PriorityTimeInterval(
101
+ 2000,
102
+ // Scale by function
103
+ () => {
104
+ const audience = this._liveRuntime.audience;
105
+ if (!audience) return 1;
106
+ // As the audience size gets bigger, we relax the update interval, since more variance is expected
107
+ const count = audience.getMembers().size;
108
+ return 1 + count / 5;
109
+ }
110
+ );
111
+ private _maxPlaybackDrift = new PriorityTimeInterval(
112
+ 1500, // Scale by function
113
+ () => {
114
+ const audience = this._liveRuntime.audience;
115
+ if (!audience) return 1;
116
+ // As the audience size gets bigger, we relax the playback drift, since more variance is expected
117
+ const count = audience.getMembers().size;
118
+ return 1 + count / 25;
119
+ }
120
+ );
83
121
  private _lastWaitPoint?: CoordinationWaitPoint;
84
122
  private initializeState: LiveDataObjectInitializeState =
85
123
  LiveDataObjectInitializeState.needed;
@@ -203,13 +241,29 @@ export class LiveMediaSessionCoordinator extends EventEmitter {
203
241
  }
204
242
 
205
243
  /**
206
- * Max amount of playback drift allowed in seconds.
244
+ * Controls whether or not to scale {@link maxPlaybackDrift} by the number of users in the session.
207
245
  *
208
246
  * @remarks
209
- * Should the local clients playback position lag by more than the specified value, the
210
- * coordinator will trigger a `catchup` action.
247
+ * As more clients join a session, it is more likely that some users will fall behind the presenter.
248
+ * It is also less likely that users will notice drift as more clients are added.
249
+ * It is usually helpful to be more lenient as more clients are added so everyone can watch all the content.
250
+ * Default value is true.
251
+ */
252
+ public get shouldScaleMaxPlaybackDrift(): boolean {
253
+ return this._maxPlaybackDrift.shouldPrioritize;
254
+ }
255
+
256
+ public set shouldScaleMaxPlaybackDrift(value: boolean) {
257
+ this._maxPlaybackDrift.shouldPrioritize = value;
258
+ }
259
+
260
+ /**
261
+ * Max amount of playback drift allowed in seconds.
262
+ * This will scale automatically according to the number of participants in the session when {@link shouldScaleMaxPlaybackDrift} is true.
211
263
  *
212
- * Defaults to a value of `1` second.
264
+ * @remarks
265
+ * Should the local clients playback position lag by more than the specified value, the coordinator will trigger a `catchup` action.
266
+ * Default value is `1.5` seconds.
213
267
  */
214
268
  public get maxPlaybackDrift(): number {
215
269
  return this._maxPlaybackDrift.seconds;
@@ -220,11 +274,30 @@ export class LiveMediaSessionCoordinator extends EventEmitter {
220
274
  }
221
275
 
222
276
  /**
223
- * Frequency with which position updates are broadcast to the rest of the group in
224
- * seconds.
277
+ * Controls whether or not to compute {@link positionUpdateInterval} based on whether user has initiated a playback command.
278
+ * Default value is true.
225
279
  *
226
280
  * @remarks
227
- * Defaults to a value of `2` seconds.
281
+ * When true, users that are simply watching but not controlling playback will report their positions less frequently.
282
+ * When a user has sent a transport command, they will begin sending position updates more frequently.
283
+ * Most Live Share apps have a concept of a primary presenter, and don't allow anyone to pause/play for the group.
284
+ * By ensuring only one/few users broadcast updates frequently, the server load is reduced considerably.
285
+ */
286
+ public get shouldScalePositionUpdateInterval(): boolean {
287
+ return this._positionUpdateInterval.shouldPrioritize;
288
+ }
289
+
290
+ public set shouldScalePositionUpdateInterval(value: boolean) {
291
+ this._positionUpdateInterval.shouldPrioritize = value;
292
+ }
293
+
294
+ /**
295
+ * Frequency with which position updates are broadcast to the rest of the group in seconds.
296
+ * When {@link shouldScalePositionUpdateInterval} is set to `true`, the value set is the minimum value.
297
+ * The value returned is the actual value used to send updates by the local user, which may be larger than the value set.
298
+ *
299
+ * @remarks
300
+ * Defaults to a minimum value of `2` seconds.
228
301
  */
229
302
  public get positionUpdateInterval(): number {
230
303
  return this._positionUpdateInterval.seconds;
@@ -274,6 +347,10 @@ export class LiveMediaSessionCoordinator extends EventEmitter {
274
347
  track: this._groupState.playbackTrack.current,
275
348
  position: position,
276
349
  });
350
+ if (this.canSendPositionUpdates) {
351
+ // User has taken initiative to send event, give priority for sending position updates
352
+ this._positionUpdateInterval.hasPriority = true;
353
+ }
277
354
  }
278
355
 
279
356
  /**
@@ -316,6 +393,10 @@ export class LiveMediaSessionCoordinator extends EventEmitter {
316
393
  track: this._groupState.playbackTrack.current,
317
394
  position: position,
318
395
  });
396
+ if (this.canSendPositionUpdates) {
397
+ // User has taken initiative to send event, give priority for sending position updates
398
+ this._positionUpdateInterval.hasPriority = true;
399
+ }
319
400
  }
320
401
 
321
402
  /**
@@ -356,12 +437,24 @@ export class LiveMediaSessionCoordinator extends EventEmitter {
356
437
  track: this._groupState.playbackTrack.current,
357
438
  position: time,
358
439
  });
440
+ if (this.canSendPositionUpdates) {
441
+ // User has taken initiative to send event, give priority for sending position updates
442
+ this._positionUpdateInterval.hasPriority = true;
443
+ }
359
444
  } catch (err) {
360
445
  await this._groupState!.syncLocalMediaSession();
361
446
  throw err;
362
447
  }
363
448
  }
364
449
 
450
+ /**
451
+ * Sets the playback rate for everyone in the session.
452
+ *
453
+ * @param playbackRate the playback rate to set.
454
+ *
455
+ * @throws
456
+ * Throws an exception if the session/coordinator hasn't been initialized or {@link canSetPlaybackRate} is false.
457
+ */
365
458
  public async setPlaybackRate(playbackRate: number): Promise<void> {
366
459
  LiveDataObjectNotInitializedError.assert(
367
460
  "LiveMediaSessionCoordinator:setPlaybackRate",
@@ -381,6 +474,10 @@ export class LiveMediaSessionCoordinator extends EventEmitter {
381
474
  { playbackRate }
382
475
  );
383
476
  await this._rateChangeEvent!.sendEvent({ playbackRate });
477
+ if (this.canSendPositionUpdates) {
478
+ // User has taken initiative to send event, give priority for sending position updates
479
+ this._positionUpdateInterval.hasPriority = true;
480
+ }
384
481
  }
385
482
 
386
483
  /**
@@ -417,6 +514,10 @@ export class LiveMediaSessionCoordinator extends EventEmitter {
417
514
  metadata: metadata,
418
515
  waitPoints: waitPoints || [],
419
516
  });
517
+ if (this.canSendPositionUpdates) {
518
+ // User has taken initiative to send event, give priority for sending position updates
519
+ this._positionUpdateInterval.hasPriority = true;
520
+ }
420
521
  }
421
522
 
422
523
  /**
@@ -451,6 +552,10 @@ export class LiveMediaSessionCoordinator extends EventEmitter {
451
552
  await this._setTrackDataEvent!.sendEvent({
452
553
  data: data,
453
554
  });
555
+ if (this.canSendPositionUpdates) {
556
+ // User has taken initiative to send event, give priority for sending position updates
557
+ this._positionUpdateInterval.hasPriority = true;
558
+ }
454
559
  }
455
560
 
456
561
  /**
@@ -570,13 +675,12 @@ export class LiveMediaSessionCoordinator extends EventEmitter {
570
675
 
571
676
  try {
572
677
  // start needs to happen after setting initializedState to "succeeded"
573
- await this._synchronizer?.start(
574
- undefined,
575
- async (evt, sender, local) => false,
576
- async (connecting) => true,
577
- false,
578
- false
579
- );
678
+ await this._synchronizer?.start({
679
+ initialState: undefined,
680
+ updateState: async (evt, sender, local) => false,
681
+ getLocalUserCanSend: async (connecting) => true,
682
+ enableBackgroundUpdates: false,
683
+ });
580
684
  } catch (error: unknown) {
581
685
  // not a fatal error for LiveMediaSession, only used for "connect" event to send new clients position updates.
582
686
  this._logger.sendErrorEvent(
@@ -603,7 +707,10 @@ export class LiveMediaSessionCoordinator extends EventEmitter {
603
707
  * @hidden
604
708
  * Called by MediaSession to trigger the sending of a position update.
605
709
  */
606
- public sendPositionUpdate(state: IMediaPlayerState): void {
710
+ public sendPositionUpdate(
711
+ state: IMediaPlayerState,
712
+ targetClientId?: string
713
+ ): void {
607
714
  LiveDataObjectNotInitializedError.assert(
608
715
  "LiveMediaSessionCoordinator:sendPositionUpdate",
609
716
  "sendPositionUpdate",
@@ -613,12 +720,15 @@ export class LiveMediaSessionCoordinator extends EventEmitter {
613
720
  if (this.canSendPositionUpdates) {
614
721
  // Send position update event
615
722
  const evt = this._groupState!.createPositionUpdateEvent(state);
616
- this._positionUpdateEvent?.sendEvent(evt).catch((err) => {
617
- this._logger.sendErrorEvent(
618
- TelemetryEvents.SessionCoordinator.PositionUpdateEventError,
619
- err
620
- );
621
- });
723
+ this._positionUpdateEvent
724
+ ?.sendEvent(evt, targetClientId)
725
+ .catch((err) => {
726
+ this._logger.sendErrorEvent(
727
+ TelemetryEvents.SessionCoordinator
728
+ .PositionUpdateEventError,
729
+ err
730
+ );
731
+ });
622
732
  } else if (this.isSuspended) {
623
733
  // send a local only position update event that was not sent as a signal, and use to handle local
624
734
  // position update for clients that have canSendPositionUpdates==false, but are suspending
@@ -730,7 +840,9 @@ export class LiveMediaSessionCoordinator extends EventEmitter {
730
840
  // Immediately send a position update
731
841
  try {
732
842
  const state = this._getPlayerState();
733
- this.sendPositionUpdate(state);
843
+ // Send only to the user that joined the session using the targetClientId prop.
844
+ // This ensures that only the user that connected receives this one-time position update, minimizing costs.
845
+ this.sendPositionUpdate(state, clientId);
734
846
  } catch (err: any) {
735
847
  // if player is not setup yet, local client might have also just joined and can't send its position.
736
848
  const playerNotSetup =
@@ -6,7 +6,7 @@
6
6
  import {
7
7
  MediaSessionCoordinatorSuspension,
8
8
  CoordinationWaitPoint,
9
- } from "./MediaSessionExtensions";
9
+ } from "./MediaSessionExtensions.js";
10
10
 
11
11
  export class LiveMediaSessionCoordinatorSuspension
12
12
  implements MediaSessionCoordinatorSuspension
@@ -2,12 +2,11 @@
2
2
  * Copyright (c) Microsoft Corporation. All rights reserved.
3
3
  * Licensed under the Microsoft Live Share SDK License.
4
4
  */
5
+ import { LiveTelemetryLogger, ILiveEvent } from "@microsoft/live-share";
5
6
  import {
6
- LiveTelemetryLogger,
7
- ILiveEvent,
8
7
  IRuntimeSignaler,
9
- } from "@microsoft/live-share";
10
- import EventEmitter from "events";
8
+ waitUntilConnected,
9
+ } from "@microsoft/live-share/internal";
11
10
  import {
12
11
  ExtendedMediaSessionAction,
13
12
  ExtendedMediaSessionPlaybackState,
@@ -16,12 +15,14 @@ import {
16
15
  ExtendedMediaSessionActionDetails,
17
16
  MediaSessionCoordinatorEvents,
18
17
  MediaSessionCoordinatorSuspension,
19
- } from "./MediaSessionExtensions";
20
- import { VolumeManager } from "./VolumeManager";
21
- import { LiveMediaSession } from "./LiveMediaSession";
22
- import { IMediaPlayer } from "./IMediaPlayer";
23
- import { ITriggerActionEvent, TelemetryEvents } from "./internals";
24
- import { waitUntilConnected } from "@microsoft/live-share/bin/internals";
18
+ } from "./MediaSessionExtensions.js";
19
+ import { VolumeManager } from "./VolumeManager.js";
20
+ import { LiveMediaSession } from "./LiveMediaSession.js";
21
+ import { IMediaPlayer } from "./IMediaPlayer.js";
22
+ import { TelemetryEvents } from "./internals/consts.js";
23
+ import { ITriggerActionEvent } from "./internals/GroupCoordinatorState.js";
24
+ import { TypedEventEmitter } from "@fluid-internal/client-utils";
25
+ import { IEvent } from "@fluidframework/core-interfaces";
25
26
 
26
27
  /**
27
28
  * Event data returned by `MediaPlayerSynchronizer` object.
@@ -49,6 +50,20 @@ export enum MediaPlayerSynchronizerEvents {
49
50
  useraction = "useraction",
50
51
  }
51
52
 
53
+ /**
54
+ * @hidden
55
+ * Emitted events from the `MediaPlayerSynchronizer` class.
56
+ */
57
+ export interface IMediaPlayerSynchronizerEvents extends IEvent {
58
+ /**
59
+ * Event listener for events emitted
60
+ * @param event update
61
+ * @param listener listener function
62
+ * @param listener.event the event instance
63
+ */
64
+ (event: string, listener: (event: any) => void): void;
65
+ }
66
+
52
67
  /**
53
68
  * Synchronizes a local HTML Media Element with a group of remote HTML Media Elements.
54
69
  *
@@ -58,7 +73,7 @@ export enum MediaPlayerSynchronizerEvents {
58
73
  * to the local player. When the group session is joined the commands will be broadcast to the
59
74
  * group in addition to being applied to the local player.
60
75
  */
61
- export class MediaPlayerSynchronizer extends EventEmitter {
76
+ export class MediaPlayerSynchronizer extends TypedEventEmitter<IMediaPlayerSynchronizerEvents> {
62
77
  private static SESSION_ACTIONS: ExtendedMediaSessionAction[] = [
63
78
  "play",
64
79
  "pause",
@@ -6,7 +6,7 @@
6
6
  import {
7
7
  ExtendedMediaSessionActionDetails,
8
8
  ExtendedMediaSessionActionHandler,
9
- } from "./MediaSessionExtensions";
9
+ } from "./MediaSessionExtensions.js";
10
10
 
11
11
  /**
12
12
  * Base class for action throttlers.
@@ -4,11 +4,11 @@
4
4
  */
5
5
 
6
6
  import { TimeInterval } from "@microsoft/live-share";
7
- import { MediaSessionActionThrottler } from "./MediaSessionActionThrottler";
7
+ import { MediaSessionActionThrottler } from "./MediaSessionActionThrottler.js";
8
8
  import {
9
9
  ExtendedMediaSessionActionDetails,
10
10
  ExtendedMediaSessionAction,
11
- } from "./MediaSessionExtensions";
11
+ } from "./MediaSessionExtensions.js";
12
12
 
13
13
  /**
14
14
  * A Throttler that passes through all actions but will only let an action be repeated once every 2 seconds.
@@ -4,7 +4,7 @@
4
4
  */
5
5
 
6
6
  import { TimeInterval } from "@microsoft/live-share";
7
- import { IMediaPlayer } from "./IMediaPlayer";
7
+ import { IMediaPlayer } from "./IMediaPlayer.js";
8
8
 
9
9
  export enum LimitLevelType {
10
10
  fixed,
@@ -61,12 +61,12 @@ export class VolumeManager {
61
61
  *
62
62
  * @remarks
63
63
  * Expressed as a value between 0.0 and 1.0. The value is applied based upon the configured
64
- * `levelType`. The default value is 0.1.
64
+ * @see LimitLevelType. The default value is 0.1.
65
65
  *
66
- * For a level type of `LevelType.fixed` the value is the exact level the volume will be
66
+ * For a level type of @see LimitLevelType.fixed the value is the exact level the volume will be
67
67
  * lowered to. The default value of 0.1 would cause the volume to be lowered to 0.1.
68
68
  *
69
- * For a level type of `LevelType.percentage` the value is the percentage by which the volume
69
+ * For a level type of @see LimitLevelType.percentage the value is the percentage by which the volume
70
70
  * level should be lowered to. The default value of 0.1 would cause the volume to be lowered
71
71
  * to 10% of its starting value.
72
72
  */
@@ -118,8 +118,8 @@ export class VolumeManager {
118
118
 
119
119
  /**
120
120
  * Limits volume based on `limitLevel` and `limitLevelType` properties.
121
- * @see `limitLevel`
122
- * @see `limitLevelType`
121
+ * @see limitLevel
122
+ * @see limitLevelType
123
123
  */
124
124
  public startLimiting(): void {
125
125
  this._isLimiting = true;
package/src/index.ts CHANGED
@@ -3,12 +3,12 @@
3
3
  * Licensed under the Microsoft Live Share SDK License.
4
4
  */
5
5
 
6
- export * from "./LiveMediaSession";
7
- export * from "./LiveMediaSessionCoordinator";
8
- export * from "./LiveMediaSessionCoordinatorSuspension";
9
- export * from "./IMediaPlayer";
10
- export * from "./MediaPlayerSynchronizer";
11
- export * from "./MediaSessionActionThrottler";
12
- export * from "./MediaSessionExtensions";
13
- export * from "./RepeatedActionThrottler";
14
- export * from "./VolumeManager";
6
+ export * from "./LiveMediaSession.js";
7
+ export * from "./LiveMediaSessionCoordinator.js";
8
+ export * from "./LiveMediaSessionCoordinatorSuspension.js";
9
+ export * from "./IMediaPlayer.js";
10
+ export * from "./MediaPlayerSynchronizer.js";
11
+ export * from "./MediaSessionActionThrottler.js";
12
+ export * from "./MediaSessionExtensions.js";
13
+ export * from "./RepeatedActionThrottler.js";
14
+ export * from "./VolumeManager.js";
@@ -6,50 +6,54 @@
6
6
  import {
7
7
  ILiveEvent,
8
8
  TimeInterval,
9
- IRuntimeSignaler,
10
9
  LiveTelemetryLogger,
11
- LiveShareRuntime,
12
10
  IEvent,
13
11
  } from "@microsoft/live-share";
14
- import EventEmitter from "events";
12
+ import {
13
+ IRuntimeSignaler,
14
+ LiveShareRuntime,
15
+ waitUntilConnected,
16
+ } from "@microsoft/live-share/internal";
15
17
  import {
16
18
  ExtendedMediaMetadata,
17
19
  CoordinationWaitPoint,
18
20
  ExtendedMediaSessionPlaybackState,
19
21
  ExtendedMediaSessionActionDetails,
20
22
  ExtendedMediaSessionActionSource,
21
- } from "../MediaSessionExtensions";
23
+ } from "../MediaSessionExtensions.js";
22
24
  import {
23
25
  GroupPlaybackTrack,
24
26
  GroupPlaybackTrackEvents,
25
27
  IPlaybackTrack,
26
28
  IPlaybackTrackChangeEvent,
27
- } from "./GroupPlaybackTrack";
29
+ } from "./GroupPlaybackTrack.js";
28
30
  import {
29
31
  GroupTransportState,
30
32
  ITransportState,
31
33
  ITransportStateChangeEvent,
32
- } from "./GroupTransportState";
34
+ } from "./GroupTransportState.js";
33
35
  import {
34
36
  GroupPlaybackPosition,
35
37
  ICurrentPlaybackPosition,
36
- } from "./GroupPlaybackPosition";
37
- import { IMediaPlayerState } from "../LiveMediaSessionCoordinator";
38
- import { GroupTransportStateEvents } from "./GroupTransportState";
38
+ } from "./GroupPlaybackPosition.js";
39
+ import { IMediaPlayerState } from "../LiveMediaSessionCoordinator.js";
40
+ import { GroupTransportStateEvents } from "./GroupTransportState.js";
39
41
  import {
40
42
  GroupPlaybackTrackData,
41
43
  PlaybackTrackDataEvents,
42
44
  IPlaybackTrackData,
43
45
  IPlaybackTrackDataChangeEvent,
44
- } from "./GroupPlaybackTrackData";
45
- import { TelemetryEvents } from "./consts";
46
- import { waitUntilConnected } from "@microsoft/live-share/bin/internals";
46
+ } from "./GroupPlaybackTrackData.js";
47
+ import { TelemetryEvents } from "./consts.js";
47
48
  import {
48
49
  GroupPlaybackRate,
49
50
  IPlaybackRate,
50
51
  IPlaybackRateChangeEvent,
51
52
  PlaybackRateEvents,
52
- } from "./GroupPlaybackRate";
53
+ } from "./GroupPlaybackRate.js";
54
+ import { TypedEventEmitter } from "@fluid-internal/client-utils";
55
+ import { IGenericTypedEvents } from "./interfaces.js";
56
+ import { PriorityTimeInterval } from "./PriorityTimeInterval.js";
53
57
 
54
58
  /**
55
59
  * @hidden
@@ -113,7 +117,7 @@ export enum GroupCoordinatorStateEvents {
113
117
  /**
114
118
  * @hidden
115
119
  */
116
- export class GroupCoordinatorState extends EventEmitter {
120
+ export class GroupCoordinatorState extends TypedEventEmitter<IGenericTypedEvents> {
117
121
  private readonly _runtime: IRuntimeSignaler;
118
122
  private readonly _liveRuntime: LiveShareRuntime;
119
123
  private readonly _logger: LiveTelemetryLogger;
@@ -142,7 +146,7 @@ export class GroupCoordinatorState extends EventEmitter {
142
146
  runtime: IRuntimeSignaler,
143
147
  liveRuntime: LiveShareRuntime,
144
148
  maxPlaybackDrift: TimeInterval,
145
- positionUpdateInterval: TimeInterval,
149
+ positionUpdateInterval: PriorityTimeInterval,
146
150
  getMediaPlayerState: () => IMediaPlayerState
147
151
  ) {
148
152
  super();