@microsoft/live-share-media 2.0.0-internal.3 → 2.0.0-internal.4

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 (41) hide show
  1. package/bin/LiveMediaSessionCoordinator.d.ts +15 -3
  2. package/bin/LiveMediaSessionCoordinator.d.ts.map +1 -1
  3. package/bin/LiveMediaSessionCoordinator.js +2 -5
  4. package/bin/LiveMediaSessionCoordinator.js.map +1 -1
  5. package/bin/MediaPlayerSynchronizer.d.ts +16 -3
  6. package/bin/MediaPlayerSynchronizer.d.ts.map +1 -1
  7. package/bin/MediaPlayerSynchronizer.js +2 -5
  8. package/bin/MediaPlayerSynchronizer.js.map +1 -1
  9. package/bin/internals/GroupCoordinatorState.d.ts +3 -3
  10. package/bin/internals/GroupCoordinatorState.d.ts.map +1 -1
  11. package/bin/internals/GroupCoordinatorState.js +2 -5
  12. package/bin/internals/GroupCoordinatorState.js.map +1 -1
  13. package/bin/internals/GroupPlaybackRate.d.ts +3 -4
  14. package/bin/internals/GroupPlaybackRate.d.ts.map +1 -1
  15. package/bin/internals/GroupPlaybackRate.js +2 -5
  16. package/bin/internals/GroupPlaybackRate.js.map +1 -1
  17. package/bin/internals/GroupPlaybackTrack.d.ts +3 -4
  18. package/bin/internals/GroupPlaybackTrack.d.ts.map +1 -1
  19. package/bin/internals/GroupPlaybackTrack.js +2 -5
  20. package/bin/internals/GroupPlaybackTrack.js.map +1 -1
  21. package/bin/internals/GroupPlaybackTrackData.d.ts +3 -4
  22. package/bin/internals/GroupPlaybackTrackData.d.ts.map +1 -1
  23. package/bin/internals/GroupPlaybackTrackData.js +2 -5
  24. package/bin/internals/GroupPlaybackTrackData.js.map +1 -1
  25. package/bin/internals/GroupTransportState.d.ts +3 -4
  26. package/bin/internals/GroupTransportState.d.ts.map +1 -1
  27. package/bin/internals/GroupTransportState.js +2 -5
  28. package/bin/internals/GroupTransportState.js.map +1 -1
  29. package/bin/internals/interfaces.d.ts +13 -0
  30. package/bin/internals/interfaces.d.ts.map +1 -1
  31. package/nyc/junit-report.json +850 -0
  32. package/nyc/junit-report.xml +54 -0
  33. package/package.json +3 -3
  34. package/src/LiveMediaSessionCoordinator.ts +16 -2
  35. package/src/MediaPlayerSynchronizer.ts +17 -2
  36. package/src/internals/GroupCoordinatorState.ts +4 -2
  37. package/src/internals/GroupPlaybackRate.ts +3 -3
  38. package/src/internals/GroupPlaybackTrack.ts +3 -3
  39. package/src/internals/GroupPlaybackTrackData.ts +3 -3
  40. package/src/internals/GroupTransportState.ts +3 -3
  41. package/src/internals/interfaces.ts +14 -0
@@ -0,0 +1,54 @@
1
+ <testsuite name="@microsoft/live-share-media" tests="52" failures="0" errors="0" skipped="0" timestamp="Thu, 28 Mar 2024 19:12:27 GMT" time="15.076">
2
+ <testcase classname="GroupPlaybackPosition" name="should start with 0 clients" time="0.001"/>
3
+ <testcase classname="GroupPlaybackPosition" name="should find local position" time="0"/>
4
+ <testcase classname="GroupPlaybackPosition" name="should update local position" time="0"/>
5
+ <testcase classname="GroupPlaybackPosition" name="should ignore older position updates" time="0"/>
6
+ <testcase classname="GroupPlaybackPosition" name="should track other client positions" time="0"/>
7
+ <testcase classname="GroupPlaybackPosition" name="should enumerate client positions" time="0"/>
8
+ <testcase classname="GroupPlaybackPosition" name="should ignore stale positions" time="0"/>
9
+ <testcase classname="GroupPlaybackPosition" name="should project position when playing" time="0"/>
10
+ <testcase classname="GroupPlaybackPosition" name="should compute max playback position relative to transport state" time="0.001"/>
11
+ <testcase classname="GroupPlaybackPosition" name="should compute target position relative to other client positions" time="0"/>
12
+ <testcase classname="GroupPlaybackPosition" name="should limit max and target position by media duration" time="0"/>
13
+ <testcase classname="GroupPlaybackPosition" name="should count number of waiting clients" time="0.001"/>
14
+ <testcase classname="GroupPlaybackPosition" name="should drop waiting count after suspension ends" time="0"/>
15
+ <testcase classname="GroupPlaybackPosition" name="should drop waiting count to 0 after all clients reach wait point" time="0"/>
16
+ <testcase classname="GroupPlaybackRate" name="updatePlaybackRate should return false for older events" time="0"/>
17
+ <testcase classname="GroupPlaybackRate" name="updatePlaybackRate should return false for events that are the same time, but clientId is higher sort" time="0"/>
18
+ <testcase classname="GroupPlaybackTrack" name="should fire &#x22;trackChange&#x22; event when no media" time="0"/>
19
+ <testcase classname="GroupPlaybackTrack" name="should switch tracks" time="0"/>
20
+ <testcase classname="GroupPlaybackTrack" name="should ignore track changes with older timestamps" time="0"/>
21
+ <testcase classname="GroupPlaybackTrack" name="should insert waitpoint if no existing waitpoints" time="0"/>
22
+ <testcase classname="GroupPlaybackTrack" name="should insert waitpoints in correct order" time="0"/>
23
+ <testcase classname="GroupPlaybackTrack" name="updateTrack should return false for events that are the same time, but clientId is higher sort" time="0"/>
24
+ <testcase classname="GroupPlaybackTrackData" name="updateData should return false for older events" time="0"/>
25
+ <testcase classname="GroupPlaybackTrackData" name="updateData should return false for events that are the same time, but clientId is higher sort" time="0"/>
26
+ <testcase classname="LiveMediaSession Manual Action Handlers (mostly testing coordinator) Fluid Test: LiveMediaSession Manual Action Handlers (mostly testing coordinator)" name="should send &#x27;positionUpdate&#x27; event when someone joins." time="0.027"/>
27
+ <testcase classname="LiveMediaSession Manual Action Handlers (mostly testing coordinator) Fluid Test: LiveMediaSession Manual Action Handlers (mostly testing coordinator)" name="should not send &#x27;positionUpdate&#x27; event if object has canSendPositionUpdates set to false" time="0.008"/>
28
+ <testcase classname="LiveMediaSession Manual Action Handlers (mostly testing coordinator) Fluid Test: LiveMediaSession Manual Action Handlers (mostly testing coordinator)" name="should send &#x27;positionUpdate&#x27; event if object has canSendPositionUpdates set to false, but is suspended" time="0.01"/>
29
+ <testcase classname="LiveMediaSession Manual Action Handlers (mostly testing coordinator) Fluid Test: LiveMediaSession Manual Action Handlers (mostly testing coordinator)" name="should send &#x27;positionUpdate&#x27; event regularly." time="0.514"/>
30
+ <testcase classname="LiveMediaSession Manual Action Handlers (mostly testing coordinator) Fluid Test: LiveMediaSession Manual Action Handlers (mostly testing coordinator)" name="should broadcast &#x27;play&#x27; transport command." time="0.022"/>
31
+ <testcase classname="LiveMediaSession Manual Action Handlers (mostly testing coordinator) Fluid Test: LiveMediaSession Manual Action Handlers (mostly testing coordinator)" name="should broadcast &#x27;pause&#x27; transport command." time="0.008"/>
32
+ <testcase classname="LiveMediaSession Manual Action Handlers (mostly testing coordinator) Fluid Test: LiveMediaSession Manual Action Handlers (mostly testing coordinator)" name="should broadcast &#x27;seekTo&#x27; transport command." time="0.006"/>
33
+ <testcase classname="LiveMediaSession Manual Action Handlers (mostly testing coordinator) Fluid Test: LiveMediaSession Manual Action Handlers (mostly testing coordinator)" name="should broadcast &#x27;setTrack&#x27; transport command." time="0.006"/>
34
+ <testcase classname="LiveMediaSession Manual Action Handlers (mostly testing coordinator) Fluid Test: LiveMediaSession Manual Action Handlers (mostly testing coordinator)" name="should broadcast &#x27;catchup&#x27; transport command." time="2.03"/>
35
+ <testcase classname="LiveMediaSession Using MediaPlayerSynchronizer Fluid Test: LiveMediaSession Using MediaPlayerSynchronizer" name="should play and pause on both" time="0.316"/>
36
+ <testcase classname="LiveMediaSession Using MediaPlayerSynchronizer Fluid Test: LiveMediaSession Using MediaPlayerSynchronizer" name="should seek forward and play then pause" time="0.318"/>
37
+ <testcase classname="LiveMediaSession Using MediaPlayerSynchronizer Fluid Test: LiveMediaSession Using MediaPlayerSynchronizer" name="should play then seek forward then pause" time="0.419"/>
38
+ <testcase classname="LiveMediaSession Using MediaPlayerSynchronizer Fluid Test: LiveMediaSession Using MediaPlayerSynchronizer" name="should play then seek backwards then keep playing" time="0.317"/>
39
+ <testcase classname="LiveMediaSession Using MediaPlayerSynchronizer Fluid Test: LiveMediaSession Using MediaPlayerSynchronizer" name="should change playback rate" time="0.216"/>
40
+ <testcase classname="LiveMediaSession Using MediaPlayerSynchronizer Fluid Test: LiveMediaSession Using MediaPlayerSynchronizer" name="should only let organizer play, pause, seek" time="0.018"/>
41
+ <testcase classname="LiveMediaSession Using MediaPlayerSynchronizer Fluid Test: LiveMediaSession Using MediaPlayerSynchronizer" name="should setTrack" time="0.309"/>
42
+ <testcase classname="LiveMediaSession Using MediaPlayerSynchronizer Fluid Test: LiveMediaSession Using MediaPlayerSynchronizer" name="should beginSeek and suspend till endSeek" time="0.319"/>
43
+ <testcase classname="LiveMediaSession Using MediaPlayerSynchronizer Fluid Test: LiveMediaSession Using MediaPlayerSynchronizer" name="should not load twice" time="0.215"/>
44
+ <testcase classname="LiveMediaSession Using MediaPlayerSynchronizer Fluid Test: LiveMediaSession Using MediaPlayerSynchronizer" name="should suspend at waitpoint with DIFFERENT player for ad" time="1.516"/>
45
+ <testcase classname="LiveMediaSession Using MediaPlayerSynchronizer Fluid Test: LiveMediaSession Using MediaPlayerSynchronizer" name="should suspend at waitpoint with SAME player for ad" time="1.516"/>
46
+ <testcase classname="LiveMediaSession Using MediaPlayerSynchronizer Fluid Test: LiveMediaSession Using MediaPlayerSynchronizer" name="client should catchup to leader" time="1.723"/>
47
+ <testcase classname="VolumeManager" name="should ramp down volume" time="0.778"/>
48
+ <testcase classname="VolumeManager" name="should ramp up volume" time="1.05"/>
49
+ <testcase classname="VolumeManager" name="should ramp down halfway, then ramp up" time="0.774"/>
50
+ <testcase classname="VolumeManager" name="ramp using selected volume" time="0.525"/>
51
+ <testcase classname="VolumeManager" name="enable limit, change selected volume, then disable limit" time="0.776"/>
52
+ <testcase classname="VolumeManager" name="ramp down with selected volume to 0.3, then up to 0.8" time="0.775"/>
53
+ <testcase classname="VolumeManager" name="test 50% limiting" time="0.526"/>
54
+ </testsuite>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@microsoft/live-share-media",
3
- "version": "2.0.0-internal.3",
3
+ "version": "2.0.0-internal.4",
4
4
  "description": "Live Share classes that synchronize media playback across clients.",
5
5
  "author": "Microsoft",
6
6
  "license": "SEE LICENSE IN LICENSE",
@@ -15,7 +15,7 @@
15
15
  "test:race": "node ./../live-share/test-for-race-conditions.js"
16
16
  },
17
17
  "devDependencies": {
18
- "@microsoft/live-share": "2.0.0-internal.3",
18
+ "@microsoft/live-share": "2.0.0-internal.4",
19
19
  "@fluidframework/mocha-test-setup": "^2.0.0-rc.1",
20
20
  "@fluidframework/test-runtime-utils": "^2.0.0-rc.1",
21
21
  "@fluidframework/test-utils": "^2.0.0-rc.1",
@@ -30,7 +30,7 @@
30
30
  "typescript": "^5.0.4"
31
31
  },
32
32
  "peerDependencies": {
33
- "@microsoft/live-share": "2.0.0-internal.3",
33
+ "@microsoft/live-share": "2.0.0-internal.4",
34
34
  "fluid-framework": "^2.0.0-rc || ^2.0.0-internal"
35
35
  },
36
36
  "repository": {
@@ -36,8 +36,9 @@ import {
36
36
  IRateChangeCommandEvent,
37
37
  } from "./internals";
38
38
  import { LiveMediaSessionCoordinatorSuspension } from "./LiveMediaSessionCoordinatorSuspension";
39
- import EventEmitter from "events";
40
39
  import { isErrorLike } from "@microsoft/live-share/bin/internals";
40
+ import { TypedEventEmitter } from "@fluid-internal/client-utils";
41
+ import { IEvent } from "@fluidframework/common-definitions";
41
42
 
42
43
  /**
43
44
  * Most recent state of the media session.
@@ -67,12 +68,25 @@ export interface IMediaPlayerState {
67
68
  positionState?: MediaPositionState;
68
69
  }
69
70
 
71
+ /**
72
+ * @hidden
73
+ */
74
+ export interface ILiveMediaSessionCoordinatorEvents extends IEvent {
75
+ /**
76
+ * Event listener for events emitted
77
+ * @param event update
78
+ * @param listener listener function
79
+ * @param listener.event the event instance
80
+ */
81
+ (event: string, listener: (event: any) => void): void;
82
+ }
83
+
70
84
  /**
71
85
  * The `LiveMediaSessionCoordinator` tracks the playback & position state of all other
72
86
  * clients being synchronized with. It is responsible for keeping the local media player
73
87
  * in sync with the group.
74
88
  */
75
- export class LiveMediaSessionCoordinator extends EventEmitter {
89
+ export class LiveMediaSessionCoordinator extends TypedEventEmitter<ILiveMediaSessionCoordinatorEvents> {
76
90
  private readonly _id: string;
77
91
  private readonly _runtime: IRuntimeSignaler;
78
92
  private readonly _liveRuntime: LiveShareRuntime;
@@ -7,7 +7,6 @@ import {
7
7
  ILiveEvent,
8
8
  IRuntimeSignaler,
9
9
  } from "@microsoft/live-share";
10
- import EventEmitter from "events";
11
10
  import {
12
11
  ExtendedMediaSessionAction,
13
12
  ExtendedMediaSessionPlaybackState,
@@ -22,6 +21,8 @@ import { LiveMediaSession } from "./LiveMediaSession";
22
21
  import { IMediaPlayer } from "./IMediaPlayer";
23
22
  import { ITriggerActionEvent, TelemetryEvents } from "./internals";
24
23
  import { waitUntilConnected } from "@microsoft/live-share/bin/internals";
24
+ import { TypedEventEmitter } from "@fluid-internal/client-utils";
25
+ import { IEvent } from "@fluidframework/common-definitions";
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",
@@ -11,7 +11,6 @@ import {
11
11
  LiveShareRuntime,
12
12
  IEvent,
13
13
  } from "@microsoft/live-share";
14
- import EventEmitter from "events";
15
14
  import {
16
15
  ExtendedMediaMetadata,
17
16
  CoordinationWaitPoint,
@@ -50,6 +49,9 @@ import {
50
49
  IPlaybackRateChangeEvent,
51
50
  PlaybackRateEvents,
52
51
  } from "./GroupPlaybackRate";
52
+ import { TypedEventEmitter } from "@fluid-internal/client-utils";
53
+ import { IEvent as FluidIEvent } from "@fluidframework/common-definitions";
54
+ import { IGenericTypedEvents } from "./interfaces";
53
55
 
54
56
  /**
55
57
  * @hidden
@@ -113,7 +115,7 @@ export enum GroupCoordinatorStateEvents {
113
115
  /**
114
116
  * @hidden
115
117
  */
116
- export class GroupCoordinatorState extends EventEmitter {
118
+ export class GroupCoordinatorState extends TypedEventEmitter<IGenericTypedEvents> {
117
119
  private readonly _runtime: IRuntimeSignaler;
118
120
  private readonly _liveRuntime: LiveShareRuntime;
119
121
  private readonly _logger: LiveTelemetryLogger;
@@ -3,9 +3,9 @@
3
3
  * Licensed under the Microsoft Live Share SDK License.
4
4
  */
5
5
 
6
- import EventEmitter from "events";
6
+ import { TypedEventEmitter } from "@fluid-internal/client-utils";
7
7
  import { ExtendedMediaSessionActionSource } from "../MediaSessionExtensions";
8
- import { IGroupStateEvent } from "./interfaces";
8
+ import { IGroupStateEvent, IGenericTypedEvents } from "./interfaces";
9
9
 
10
10
  /**
11
11
  * @hidden
@@ -33,7 +33,7 @@ export interface IPlaybackRateChangeEvent extends IGroupStateEvent {
33
33
  /**
34
34
  * @hidden
35
35
  */
36
- export class GroupPlaybackRate extends EventEmitter {
36
+ export class GroupPlaybackRate extends TypedEventEmitter<IGenericTypedEvents> {
37
37
  private _current: IPlaybackRate;
38
38
 
39
39
  constructor() {
@@ -3,14 +3,14 @@
3
3
  * Licensed under the Microsoft Live Share SDK License.
4
4
  */
5
5
 
6
- import EventEmitter from "events";
7
6
  import { IMediaPlayerState } from "../LiveMediaSessionCoordinator";
8
7
  import {
9
8
  CoordinationWaitPoint,
10
9
  ExtendedMediaMetadata,
11
10
  ExtendedMediaSessionActionSource,
12
11
  } from "../MediaSessionExtensions";
13
- import { IGroupStateEvent } from "./interfaces";
12
+ import { IGenericTypedEvents, IGroupStateEvent } from "./interfaces";
13
+ import { TypedEventEmitter } from "@fluid-internal/client-utils";
14
14
 
15
15
  /**
16
16
  * @hidden
@@ -39,7 +39,7 @@ export interface IPlaybackTrackChangeEvent extends IGroupStateEvent {
39
39
  /**
40
40
  * @hidden
41
41
  */
42
- export class GroupPlaybackTrack extends EventEmitter {
42
+ export class GroupPlaybackTrack extends TypedEventEmitter<IGenericTypedEvents> {
43
43
  private readonly _getMediaPlayerState: () => IMediaPlayerState;
44
44
  private _current: IPlaybackTrack;
45
45
 
@@ -3,13 +3,13 @@
3
3
  * Licensed under the Microsoft Live Share SDK License.
4
4
  */
5
5
 
6
- import EventEmitter from "events";
7
6
  import {
8
7
  GroupPlaybackTrack,
9
8
  GroupPlaybackTrackEvents,
10
9
  } from "./GroupPlaybackTrack";
11
10
  import { ExtendedMediaSessionActionSource } from "../MediaSessionExtensions";
12
- import { IGroupStateEvent } from "./interfaces";
11
+ import { IGenericTypedEvents, IGroupStateEvent } from "./interfaces";
12
+ import { TypedEventEmitter } from "@fluid-internal/client-utils";
13
13
 
14
14
  /**
15
15
  * @hidden
@@ -37,7 +37,7 @@ export interface IPlaybackTrackDataChangeEvent extends IGroupStateEvent {
37
37
  /**
38
38
  * @hidden
39
39
  */
40
- export class GroupPlaybackTrackData extends EventEmitter {
40
+ export class GroupPlaybackTrackData extends TypedEventEmitter<IGenericTypedEvents> {
41
41
  private _track: GroupPlaybackTrack;
42
42
  private _current: IPlaybackTrackData;
43
43
 
@@ -4,7 +4,7 @@
4
4
  */
5
5
 
6
6
  import { LiveShareRuntime } from "@microsoft/live-share";
7
- import EventEmitter from "events";
7
+ import { TypedEventEmitter } from "@fluid-internal/client-utils";
8
8
  import { IMediaPlayerState } from "../LiveMediaSessionCoordinator";
9
9
  import {
10
10
  ExtendedMediaSessionPlaybackState,
@@ -15,7 +15,7 @@ import {
15
15
  GroupPlaybackTrack,
16
16
  GroupPlaybackTrackEvents,
17
17
  } from "./GroupPlaybackTrack";
18
- import { IGroupStateEvent } from "./interfaces";
18
+ import { IGenericTypedEvents, IGroupStateEvent } from "./interfaces";
19
19
  import { GroupPlaybackRate } from "./GroupPlaybackRate";
20
20
 
21
21
  /**
@@ -46,7 +46,7 @@ export interface ITransportStateChangeEvent extends IGroupStateEvent {
46
46
  /**
47
47
  * @hidden
48
48
  */
49
- export class GroupTransportState extends EventEmitter {
49
+ export class GroupTransportState extends TypedEventEmitter<IGenericTypedEvents> {
50
50
  private readonly _getMediaPlayerState: () => IMediaPlayerState;
51
51
  private _track: GroupPlaybackTrack;
52
52
  private _playbackRate: GroupPlaybackRate;
@@ -1,4 +1,5 @@
1
1
  import { IEvent } from "@microsoft/live-share";
2
+ import { IEvent as IFluidEvent } from "@fluidframework/common-definitions";
2
3
  import { ExtendedMediaSessionActionSource } from "../MediaSessionExtensions";
3
4
 
4
5
  /**
@@ -8,3 +9,16 @@ export interface IGroupStateEvent extends IEvent {
8
9
  clientId: string;
9
10
  source: ExtendedMediaSessionActionSource;
10
11
  }
12
+
13
+ /**
14
+ * @hidden
15
+ */
16
+ export interface IGenericTypedEvents extends IFluidEvent {
17
+ /**
18
+ * Event listener for events emitted
19
+ * @param event update
20
+ * @param listener listener function
21
+ * @param listener.event the event instance
22
+ */
23
+ (event: string, listener: (event: any) => void): void;
24
+ }