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

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 (89) 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 +174 -163
  16. package/bin/MediaPlayerSynchronizer.d.ts.map +1 -1
  17. package/bin/MediaPlayerSynchronizer.js +503 -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.d.ts.map +1 -1
  29. package/bin/VolumeManager.js +174 -174
  30. package/bin/VolumeManager.js.map +1 -1
  31. package/bin/index.d.ts +13 -13
  32. package/bin/index.js +29 -29
  33. package/bin/internals/GroupCoordinatorState.d.ts +93 -92
  34. package/bin/internals/GroupCoordinatorState.d.ts.map +1 -1
  35. package/bin/internals/GroupCoordinatorState.js +407 -404
  36. package/bin/internals/GroupCoordinatorState.js.map +1 -1
  37. package/bin/internals/GroupPlaybackPosition.d.ts +67 -66
  38. package/bin/internals/GroupPlaybackPosition.d.ts.map +1 -1
  39. package/bin/internals/GroupPlaybackPosition.js +165 -166
  40. package/bin/internals/GroupPlaybackPosition.js.map +1 -1
  41. package/bin/internals/GroupPlaybackTrack.d.ts +45 -45
  42. package/bin/internals/GroupPlaybackTrack.d.ts.map +1 -1
  43. package/bin/internals/GroupPlaybackTrack.js +121 -121
  44. package/bin/internals/GroupPlaybackTrackData.d.ts +39 -39
  45. package/bin/internals/GroupPlaybackTrackData.d.ts.map +1 -1
  46. package/bin/internals/GroupPlaybackTrackData.js +69 -69
  47. package/bin/internals/GroupTransportState.d.ts +49 -48
  48. package/bin/internals/GroupTransportState.d.ts.map +1 -1
  49. package/bin/internals/GroupTransportState.js +111 -111
  50. package/bin/internals/GroupTransportState.js.map +1 -1
  51. package/bin/internals/consts.d.ts +75 -72
  52. package/bin/internals/consts.d.ts.map +1 -1
  53. package/bin/internals/consts.js +84 -81
  54. package/bin/internals/consts.js.map +1 -1
  55. package/bin/internals/index.d.ts +10 -10
  56. package/bin/internals/index.js +26 -26
  57. package/package.json +16 -9
  58. package/src/LiveMediaSession.ts +24 -20
  59. package/src/LiveMediaSessionCoordinator.ts +101 -29
  60. package/src/MediaPlayerSynchronizer.ts +47 -15
  61. package/src/VolumeManager.ts +4 -1
  62. package/src/internals/GroupCoordinatorState.ts +50 -35
  63. package/src/internals/GroupPlaybackPosition.ts +8 -7
  64. package/src/internals/GroupPlaybackTrack.ts +2 -2
  65. package/src/internals/GroupPlaybackTrackData.ts +2 -2
  66. package/src/internals/GroupTransportState.ts +11 -4
  67. package/src/internals/consts.ts +4 -0
  68. package/typedoc.json +10 -0
  69. package/bin/EphemeralMediaSession.d.ts +0 -102
  70. package/bin/EphemeralMediaSession.d.ts.map +0 -1
  71. package/bin/EphemeralMediaSession.js +0 -226
  72. package/bin/EphemeralMediaSession.js.map +0 -1
  73. package/bin/EphemeralMediaSessionCoordinator.d.ts +0 -228
  74. package/bin/EphemeralMediaSessionCoordinator.d.ts.map +0 -1
  75. package/bin/EphemeralMediaSessionCoordinator.js +0 -396
  76. package/bin/EphemeralMediaSessionCoordinator.js.map +0 -1
  77. package/bin/EphemeralMediaSessionCoordinatorSuspension.d.ts +0 -20
  78. package/bin/EphemeralMediaSessionCoordinatorSuspension.d.ts.map +0 -1
  79. package/bin/EphemeralMediaSessionCoordinatorSuspension.js +0 -28
  80. package/bin/EphemeralMediaSessionCoordinatorSuspension.js.map +0 -1
  81. package/bin/VolumeLimiter.d.ts +0 -70
  82. package/bin/VolumeLimiter.d.ts.map +0 -1
  83. package/bin/VolumeLimiter.js +0 -170
  84. package/bin/VolumeLimiter.js.map +0 -1
  85. package/src/test/GroupPlaybackPosition.spec.ts +0 -600
  86. package/src/test/GroupPlaybackTrack.spec.ts +0 -122
  87. package/src/test/SharedMediaSession.spec.ts +0 -149
  88. package/src/test/SharedMediaSessionCoordinator.spec.ts +0 -271
  89. package/src/test/VolumeManager.spec.ts +0 -219
@@ -1,170 +0,0 @@
1
- "use strict";
2
- /**
3
- * Copyright (c) Microsoft Corporation. All rights reserved.
4
- * Licensed under the Microsoft Live Share SDK License.
5
- */
6
- Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.VolumeLimiter = exports.LevelType = void 0;
8
- const live_share_1 = require("@microsoft/live-share");
9
- var LevelType;
10
- (function (LevelType) {
11
- LevelType[LevelType["fixed"] = 0] = "fixed";
12
- LevelType[LevelType["percentage"] = 1] = "percentage";
13
- })(LevelType = exports.LevelType || (exports.LevelType = {}));
14
- class VolumeLimiter {
15
- constructor(player) {
16
- // Settings
17
- this._duration = new live_share_1.TimeInterval(2000);
18
- this._rampDownDuration = new live_share_1.TimeInterval(500);
19
- this._rampUpDuration = new live_share_1.TimeInterval(500);
20
- this._level = 0.1;
21
- this._levelType = LevelType.fixed;
22
- // Running state
23
- this._running = false;
24
- this._endTime = 0;
25
- this._startTime = 0;
26
- this._startVolume = 0;
27
- this._inRamp = false;
28
- this._player = player;
29
- }
30
- /**
31
- * Time, in seconds, that the volume should be lowered.
32
- *
33
- * @remarks
34
- * Applications should periodically call `lowerVolume()` to keep the volume lowered.
35
- */
36
- get duration() {
37
- return this._duration.seconds;
38
- }
39
- set duration(value) {
40
- this._duration.seconds = Math.abs(value);
41
- }
42
- /**
43
- * Target level to lower volume to.
44
- *
45
- * @remarks
46
- * Expressed as a value between 0.0 and 1.0. The value is applied based upon the configured
47
- * `levelType`. The default value is 0.2.
48
- *
49
- * For a level type of `LevelType.fixed` the value is the exact level the volume will be
50
- * lowered to. The default value of 0.2 would cause the volume to be lowered to 0.2.
51
- *
52
- * For a level type of `LevelType.percentage` the value is the percentage by which the volume
53
- * level should be lowered to. The default value of 0.2 would cause the volume to be lowered
54
- * to 20% of its starting value.
55
- */
56
- get level() {
57
- return this._level;
58
- }
59
- set level(value) {
60
- if (value < 0 || value > 1.0) {
61
- throw new Error(`VolumeLimiter: cannot set level to ${value}. Level must be between 0.0 and 1.0.`);
62
- }
63
- this._level = value;
64
- }
65
- /**
66
- * The type of level represented by the `level` property.
67
- */
68
- get levelType() {
69
- return this._levelType;
70
- }
71
- set levelType(value) {
72
- this._levelType = value;
73
- }
74
- /**
75
- * Amount of time, in seconds, it should take to ramp the volume down to the desired level.
76
- */
77
- get rampDownDuration() {
78
- return this._rampDownDuration.seconds;
79
- }
80
- set rampDownDuration(value) {
81
- this._rampDownDuration.seconds = Math.abs(value);
82
- }
83
- /**
84
- * Amount of time, in seconds, it should take to ramp the volume back up to the original level.
85
- */
86
- get rampUpDuration() {
87
- return this._rampUpDuration.seconds;
88
- }
89
- set rampUpDuration(value) {
90
- this._rampUpDuration.seconds = Math.abs(value);
91
- }
92
- /**
93
- * Temporarily lowers an audio sources volume.
94
- */
95
- lowerVolume() {
96
- this._endTime = new Date().getTime() + this._duration.milliseconds;
97
- if (!this._running) {
98
- this.startLimiter();
99
- }
100
- }
101
- startLimiter() {
102
- const adjustVolume = () => {
103
- const now = new Date().getTime();
104
- if (now < this._endTime) {
105
- // Make no adjustment if muted
106
- if (!this._player.muted) {
107
- // Compute adjusted volume level
108
- let volume;
109
- const targetVolume = this.computeTargetVolume();
110
- const rampRange = this._startVolume - targetVolume;
111
- const rampUpStart = this._endTime - this._rampUpDuration.milliseconds;
112
- const rampDownEnd = this._startTime + this._rampDownDuration.milliseconds;
113
- if (now > rampUpStart) {
114
- // We're about to end so ramping up
115
- const progress = (now - rampUpStart) / this._rampUpDuration.milliseconds;
116
- volume = targetVolume + (rampRange * progress);
117
- this._player.volume = volume;
118
- this._inRamp = true;
119
- }
120
- else if (now < rampDownEnd) {
121
- // We just begun so ramping down
122
- const remaining = (rampDownEnd - now) / this._rampUpDuration.milliseconds;
123
- volume = targetVolume + (rampRange * remaining);
124
- this._player.volume = volume;
125
- this._inRamp = true;
126
- }
127
- else if (this._inRamp) {
128
- // We're at the end of a ramp
129
- volume = targetVolume;
130
- this._player.volume = volume;
131
- this._inRamp = false;
132
- }
133
- }
134
- // Schedule next animation frame
135
- this.scheduleAnimationFrame(adjustVolume);
136
- }
137
- else {
138
- // Reset volume to original level
139
- this._player.volume = this._startVolume;
140
- this._running = false;
141
- this._endTime = 0;
142
- this._startTime = 0;
143
- this._startVolume = 0;
144
- }
145
- };
146
- this._running = true;
147
- this._startTime = new Date().getTime();
148
- this._startVolume = this._player.volume;
149
- this.scheduleAnimationFrame(adjustVolume);
150
- }
151
- scheduleAnimationFrame(callback) {
152
- if (requestAnimationFrame) {
153
- requestAnimationFrame(callback);
154
- }
155
- else {
156
- setTimeout(callback, 20);
157
- }
158
- }
159
- computeTargetVolume() {
160
- switch (this._levelType) {
161
- case LevelType.percentage:
162
- return this._startVolume * this._level;
163
- case LevelType.fixed:
164
- default:
165
- return this._level;
166
- }
167
- }
168
- }
169
- exports.VolumeLimiter = VolumeLimiter;
170
- //# sourceMappingURL=VolumeLimiter.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"VolumeLimiter.js","sourceRoot":"","sources":["../src/VolumeLimiter.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEF,sDAAqD;AAGtD,IAAY,SAA+B;AAA3C,WAAY,SAAS;IAAG,2CAAK,CAAA;IAAE,qDAAU,CAAA;AAAC,CAAC,EAA/B,SAAS,GAAT,iBAAS,KAAT,iBAAS,QAAsB;AAE3C,MAAa,aAAa;IAiBtB,YAAY,MAAoB;QAdhC,WAAW;QACM,cAAS,GAAG,IAAI,yBAAY,CAAC,IAAI,CAAC,CAAC;QACnC,sBAAiB,GAAG,IAAI,yBAAY,CAAC,GAAG,CAAC,CAAC;QAC1C,oBAAe,GAAG,IAAI,yBAAY,CAAC,GAAG,CAAC,CAAC;QACjD,WAAM,GAAW,GAAG,CAAA;QACpB,eAAU,GAAc,SAAS,CAAC,KAAK,CAAC;QAEhD,gBAAgB;QACR,aAAQ,GAAG,KAAK,CAAC;QACjB,aAAQ,GAAG,CAAC,CAAC;QACb,eAAU,GAAG,CAAC,CAAC;QACf,iBAAY,GAAG,CAAC,CAAC;QACjB,YAAO,GAAG,KAAK,CAAC;QAGpB,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;IAC1B,CAAC;IAED;;;;;OAKG;IACH,IAAW,QAAQ;QACf,OAAO,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC;IAClC,CAAC;IAED,IAAW,QAAQ,CAAC,KAAa;QAC7B,IAAI,CAAC,SAAS,CAAC,OAAO,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IAC7C,CAAC;IAED;;;;;;;;;;;;;OAaG;IACH,IAAW,KAAK;QACZ,OAAO,IAAI,CAAC,MAAM,CAAC;IACvB,CAAC;IAED,IAAW,KAAK,CAAC,KAAa;QAC1B,IAAI,KAAK,GAAG,CAAC,IAAI,KAAK,GAAG,GA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