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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (86) hide show
  1. package/LICENSE +64 -61
  2. package/README.md +7 -13
  3. package/bin/IMediaPlayer.d.ts +20 -20
  4. package/bin/IMediaPlayer.js +6 -6
  5. package/bin/LiveMediaSession.d.ts +90 -94
  6. package/bin/LiveMediaSession.d.ts.map +1 -1
  7. package/bin/LiveMediaSession.js +228 -231
  8. package/bin/LiveMediaSession.js.map +1 -1
  9. package/bin/LiveMediaSessionCoordinator.d.ts +238 -227
  10. package/bin/LiveMediaSessionCoordinator.d.ts.map +1 -1
  11. package/bin/LiveMediaSessionCoordinator.js +476 -407
  12. package/bin/LiveMediaSessionCoordinator.js.map +1 -1
  13. package/bin/LiveMediaSessionCoordinatorSuspension.d.ts +19 -19
  14. package/bin/LiveMediaSessionCoordinatorSuspension.js +27 -27
  15. package/bin/MediaPlayerSynchronizer.d.ts +173 -163
  16. package/bin/MediaPlayerSynchronizer.d.ts.map +1 -1
  17. package/bin/MediaPlayerSynchronizer.js +491 -468
  18. package/bin/MediaPlayerSynchronizer.js.map +1 -1
  19. package/bin/MediaSessionActionThrottler.d.ts +11 -11
  20. package/bin/MediaSessionActionThrottler.js +13 -13
  21. package/bin/MediaSessionExtensions.d.ts +34 -34
  22. package/bin/MediaSessionExtensions.d.ts.map +1 -1
  23. package/bin/MediaSessionExtensions.js +12 -12
  24. package/bin/RepeatedActionThrottler.d.ts +19 -19
  25. package/bin/RepeatedActionThrottler.js +62 -62
  26. package/bin/RepeatedActionThrottler.js.map +1 -1
  27. package/bin/VolumeManager.d.ts +83 -83
  28. package/bin/VolumeManager.js +174 -174
  29. package/bin/index.d.ts +13 -13
  30. package/bin/index.js +29 -29
  31. package/bin/internals/GroupCoordinatorState.d.ts +93 -92
  32. package/bin/internals/GroupCoordinatorState.d.ts.map +1 -1
  33. package/bin/internals/GroupCoordinatorState.js +407 -404
  34. package/bin/internals/GroupCoordinatorState.js.map +1 -1
  35. package/bin/internals/GroupPlaybackPosition.d.ts +67 -66
  36. package/bin/internals/GroupPlaybackPosition.d.ts.map +1 -1
  37. package/bin/internals/GroupPlaybackPosition.js +166 -166
  38. package/bin/internals/GroupPlaybackPosition.js.map +1 -1
  39. package/bin/internals/GroupPlaybackTrack.d.ts +45 -45
  40. package/bin/internals/GroupPlaybackTrack.d.ts.map +1 -1
  41. package/bin/internals/GroupPlaybackTrack.js +121 -121
  42. package/bin/internals/GroupPlaybackTrackData.d.ts +39 -39
  43. package/bin/internals/GroupPlaybackTrackData.d.ts.map +1 -1
  44. package/bin/internals/GroupPlaybackTrackData.js +69 -69
  45. package/bin/internals/GroupTransportState.d.ts +49 -48
  46. package/bin/internals/GroupTransportState.d.ts.map +1 -1
  47. package/bin/internals/GroupTransportState.js +111 -111
  48. package/bin/internals/GroupTransportState.js.map +1 -1
  49. package/bin/internals/consts.d.ts +75 -72
  50. package/bin/internals/consts.d.ts.map +1 -1
  51. package/bin/internals/consts.js +84 -81
  52. package/bin/internals/consts.js.map +1 -1
  53. package/bin/internals/index.d.ts +10 -10
  54. package/bin/internals/index.js +26 -26
  55. package/package.json +9 -7
  56. package/src/LiveMediaSession.ts +24 -20
  57. package/src/LiveMediaSessionCoordinator.ts +101 -29
  58. package/src/MediaPlayerSynchronizer.ts +30 -14
  59. package/src/internals/GroupCoordinatorState.ts +49 -34
  60. package/src/internals/GroupPlaybackPosition.ts +7 -3
  61. package/src/internals/GroupPlaybackTrack.ts +2 -2
  62. package/src/internals/GroupPlaybackTrackData.ts +2 -2
  63. package/src/internals/GroupTransportState.ts +11 -4
  64. package/src/internals/consts.ts +4 -0
  65. package/typedoc.json +10 -0
  66. package/bin/EphemeralMediaSession.d.ts +0 -102
  67. package/bin/EphemeralMediaSession.d.ts.map +0 -1
  68. package/bin/EphemeralMediaSession.js +0 -226
  69. package/bin/EphemeralMediaSession.js.map +0 -1
  70. package/bin/EphemeralMediaSessionCoordinator.d.ts +0 -228
  71. package/bin/EphemeralMediaSessionCoordinator.d.ts.map +0 -1
  72. package/bin/EphemeralMediaSessionCoordinator.js +0 -396
  73. package/bin/EphemeralMediaSessionCoordinator.js.map +0 -1
  74. package/bin/EphemeralMediaSessionCoordinatorSuspension.d.ts +0 -20
  75. package/bin/EphemeralMediaSessionCoordinatorSuspension.d.ts.map +0 -1
  76. package/bin/EphemeralMediaSessionCoordinatorSuspension.js +0 -28
  77. package/bin/EphemeralMediaSessionCoordinatorSuspension.js.map +0 -1
  78. package/bin/VolumeLimiter.d.ts +0 -70
  79. package/bin/VolumeLimiter.d.ts.map +0 -1
  80. package/bin/VolumeLimiter.js +0 -170
  81. package/bin/VolumeLimiter.js.map +0 -1
  82. package/src/test/GroupPlaybackPosition.spec.ts +0 -600
  83. package/src/test/GroupPlaybackTrack.spec.ts +0 -122
  84. package/src/test/SharedMediaSession.spec.ts +0 -149
  85. package/src/test/SharedMediaSessionCoordinator.spec.ts +0 -271
  86. package/src/test/VolumeManager.spec.ts +0 -219
@@ -1,219 +0,0 @@
1
- import { strict as assert } from "assert";
2
- import { IMediaPlayer } from "../IMediaPlayer";
3
- import { LimitLevelType, VolumeManager } from "../VolumeManager";
4
- import { Deferred } from "@microsoft/live-share/src/test/Deferred";
5
-
6
- describe("VolumeManager", () => {
7
- it("should ramp down volume", async () => {
8
- const testAwait = new Deferred();
9
- const player = new TestMediaPlayer();
10
- player.volume = 1.0;
11
- const volumeManager = new VolumeManager(player);
12
-
13
- assert(player.volume == 1.0);
14
- volumeManager.startLimiting();
15
- setTimeout(() => {
16
- // check volume at halfway point
17
- assert(player.volume > 0.4);
18
- assert(player.volume < 0.6);
19
- }, (volumeManager.volumeChangeDuration * 1000) / 2);
20
-
21
- setTimeout(() => {
22
- // check volume at end with 20ms of leeway
23
- assert(player.volume == volumeManager.limitLevel);
24
- testAwait.resolve();
25
- }, volumeManager.volumeChangeDuration * 1000 + 20);
26
-
27
- await testAwait.promise;
28
- });
29
-
30
- it("should ramp up volume", async () => {
31
- const testAwait = new Deferred();
32
- const player = new TestMediaPlayer();
33
- player.volume = 1.0;
34
- const volumeManager = new VolumeManager(player);
35
-
36
- // limit at start
37
- volumeManager.startLimiting();
38
-
39
- // when limited all the way, test ramp up
40
- setTimeout(() => {
41
- assert(player.volume == volumeManager.limitLevel);
42
- volumeManager.stopLimiting();
43
-
44
- setTimeout(() => {
45
- // check volume at halfway point
46
- assert(player.volume > 0.4);
47
- assert(player.volume < 0.6);
48
- }, (volumeManager.volumeChangeDuration * 1000) / 2);
49
-
50
- setTimeout(() => {
51
- // check volume at end with 20ms of leeway
52
- assert(player.volume == volumeManager.volume);
53
- testAwait.resolve();
54
- }, volumeManager.volumeChangeDuration * 1000 + 20);
55
- }, volumeManager.volumeChangeDuration * 1000 + 20);
56
-
57
- await testAwait.promise;
58
- });
59
-
60
- it("should ramp down halfway, then ramp up", async () => {
61
- const testAwait = new Deferred();
62
- const player = new TestMediaPlayer();
63
- player.volume = 1.0;
64
-
65
- const volumeManager = new VolumeManager(player);
66
-
67
- volumeManager.startLimiting();
68
- setTimeout(() => {
69
- // check volume at halfway point, begin ramping other direction
70
- assert(player.volume > 0.4);
71
- assert(player.volume < 0.6);
72
- volumeManager.stopLimiting();
73
-
74
- setTimeout(() => {
75
- // check volume at end with 20ms of leeway
76
- assert(player.volume == volumeManager.volume);
77
- testAwait.resolve();
78
- }, volumeManager.volumeChangeDuration * 1000 + 20);
79
- }, (volumeManager.volumeChangeDuration * 1000) / 2);
80
-
81
- await testAwait.promise;
82
- });
83
-
84
- it("ramp using selected volume", async () => {
85
- const testAwait = new Deferred();
86
- const player = new TestMediaPlayer();
87
- player.volume = 1.0;
88
-
89
- const volumeManager = new VolumeManager(player);
90
-
91
- volumeManager.volume = 0.3;
92
- setTimeout(() => {
93
- // check volume at halfway point
94
- assert(player.volume > 0.6);
95
- assert(player.volume < 0.7);
96
- }, (volumeManager.volumeChangeDuration * 1000) / 2);
97
-
98
- setTimeout(() => {
99
- // check volume at end with 20ms of leeway
100
- assert(player.volume == volumeManager.volume);
101
- testAwait.resolve();
102
- }, volumeManager.volumeChangeDuration * 1000 + 20);
103
-
104
- await testAwait.promise;
105
- });
106
-
107
- it("enable limit, change selected volume, then disable limit", async () => {
108
- const testAwait = new Deferred();
109
- const player = new TestMediaPlayer();
110
- player.volume = 1.0;
111
- const volumeManager = new VolumeManager(player);
112
-
113
- volumeManager.startLimiting();
114
- setTimeout(() => {
115
- // check volume at halfway point, begin ramping other direction with lower selected volume
116
- assert(player.volume > 0.4);
117
- assert(player.volume < 0.6);
118
-
119
- volumeManager.volume = 0.7;
120
- volumeManager.stopLimiting();
121
-
122
- setTimeout(() => {
123
- // check volume at end with 20ms of leeway
124
- assert(player.volume === volumeManager.volume);
125
- testAwait.resolve();
126
- }, volumeManager.volumeChangeDuration * 1000 + 20);
127
- }, (volumeManager.volumeChangeDuration * 1000) / 2);
128
-
129
- await testAwait.promise;
130
- });
131
-
132
- it("ramp down with selected volume to 0.3, then up to 0.8", async () => {
133
- const testAwait = new Deferred();
134
- const player = new TestMediaPlayer();
135
- player.volume = 1.0;
136
-
137
- const volumeManager = new VolumeManager(player);
138
- volumeManager.volume = 0.3;
139
-
140
- setTimeout(() => {
141
- // check volume at halfway point
142
- assert(player.volume > 0.6);
143
- assert(player.volume < 0.7);
144
- volumeManager.volume = 0.8;
145
-
146
- setTimeout(() => {
147
- // check volume at end with 20ms of leeway
148
- assert(player.volume == volumeManager.volume);
149
- testAwait.resolve();
150
- }, volumeManager.volumeChangeDuration * 1000 + 20);
151
- }, (volumeManager.volumeChangeDuration * 1000) / 2);
152
-
153
- await testAwait.promise;
154
- });
155
-
156
- it("test 50% limiting", async () => {
157
- const testAwait = new Deferred();
158
- const player = new TestMediaPlayer();
159
- player.volume = 1.0;
160
-
161
- const volumeManager = new VolumeManager(player);
162
- volumeManager.limitLevelType = LimitLevelType.percentage;
163
- volumeManager.limitLevel = 0.5;
164
-
165
- volumeManager.startLimiting();
166
-
167
- setTimeout(() => {
168
- // check volume at halfway point
169
- assert(player.volume > 0.7);
170
- assert(player.volume < 0.8);
171
- }, (volumeManager.volumeChangeDuration * 1000) / 2);
172
-
173
- setTimeout(() => {
174
- // check volume at end with 20ms of leeway
175
- assert(
176
- player.volume == volumeManager.limitLevel * volumeManager.volume
177
- );
178
- testAwait.resolve();
179
- }, volumeManager.volumeChangeDuration * 1000 + 20);
180
-
181
- await testAwait.promise;
182
- });
183
- });
184
-
185
- // test implementation
186
- class TestMediaPlayer implements IMediaPlayer {
187
- currentSrc: string;
188
- currentTime: number;
189
- duration: number;
190
- ended: boolean;
191
- muted: boolean;
192
- paused: boolean;
193
- playbackRate: number;
194
- src: string;
195
- volume: number;
196
- load(): void {
197
- throw new Error("Method not implemented.");
198
- }
199
- pause(): void {
200
- throw new Error("Method not implemented.");
201
- }
202
- play(): Promise<void> {
203
- throw new Error("Method not implemented.");
204
- }
205
- addEventListener(
206
- type: string,
207
- listener: EventListenerOrEventListenerObject,
208
- options?: boolean | AddEventListenerOptions | undefined
209
- ): void {
210
- throw new Error("Method not implemented.");
211
- }
212
- removeEventListener(
213
- type: string,
214
- listener: EventListenerOrEventListenerObject,
215
- options?: boolean | EventListenerOptions | undefined
216
- ): void {
217
- throw new Error("Method not implemented.");
218
- }
219
- }