@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.
- package/LICENSE +64 -61
- package/README.md +7 -13
- package/bin/IMediaPlayer.d.ts +20 -20
- package/bin/IMediaPlayer.js +6 -6
- package/bin/LiveMediaSession.d.ts +90 -94
- package/bin/LiveMediaSession.d.ts.map +1 -1
- package/bin/LiveMediaSession.js +228 -231
- package/bin/LiveMediaSession.js.map +1 -1
- package/bin/LiveMediaSessionCoordinator.d.ts +238 -227
- package/bin/LiveMediaSessionCoordinator.d.ts.map +1 -1
- package/bin/LiveMediaSessionCoordinator.js +476 -407
- package/bin/LiveMediaSessionCoordinator.js.map +1 -1
- package/bin/LiveMediaSessionCoordinatorSuspension.d.ts +19 -19
- package/bin/LiveMediaSessionCoordinatorSuspension.js +27 -27
- package/bin/MediaPlayerSynchronizer.d.ts +173 -163
- package/bin/MediaPlayerSynchronizer.d.ts.map +1 -1
- package/bin/MediaPlayerSynchronizer.js +491 -468
- package/bin/MediaPlayerSynchronizer.js.map +1 -1
- package/bin/MediaSessionActionThrottler.d.ts +11 -11
- package/bin/MediaSessionActionThrottler.js +13 -13
- package/bin/MediaSessionExtensions.d.ts +34 -34
- package/bin/MediaSessionExtensions.d.ts.map +1 -1
- package/bin/MediaSessionExtensions.js +12 -12
- package/bin/RepeatedActionThrottler.d.ts +19 -19
- package/bin/RepeatedActionThrottler.js +62 -62
- package/bin/RepeatedActionThrottler.js.map +1 -1
- package/bin/VolumeManager.d.ts +83 -83
- package/bin/VolumeManager.js +174 -174
- package/bin/index.d.ts +13 -13
- package/bin/index.js +29 -29
- package/bin/internals/GroupCoordinatorState.d.ts +93 -92
- package/bin/internals/GroupCoordinatorState.d.ts.map +1 -1
- package/bin/internals/GroupCoordinatorState.js +407 -404
- package/bin/internals/GroupCoordinatorState.js.map +1 -1
- package/bin/internals/GroupPlaybackPosition.d.ts +67 -66
- package/bin/internals/GroupPlaybackPosition.d.ts.map +1 -1
- package/bin/internals/GroupPlaybackPosition.js +166 -166
- package/bin/internals/GroupPlaybackPosition.js.map +1 -1
- package/bin/internals/GroupPlaybackTrack.d.ts +45 -45
- package/bin/internals/GroupPlaybackTrack.d.ts.map +1 -1
- package/bin/internals/GroupPlaybackTrack.js +121 -121
- package/bin/internals/GroupPlaybackTrackData.d.ts +39 -39
- package/bin/internals/GroupPlaybackTrackData.d.ts.map +1 -1
- package/bin/internals/GroupPlaybackTrackData.js +69 -69
- package/bin/internals/GroupTransportState.d.ts +49 -48
- package/bin/internals/GroupTransportState.d.ts.map +1 -1
- package/bin/internals/GroupTransportState.js +111 -111
- package/bin/internals/GroupTransportState.js.map +1 -1
- package/bin/internals/consts.d.ts +75 -72
- package/bin/internals/consts.d.ts.map +1 -1
- package/bin/internals/consts.js +84 -81
- package/bin/internals/consts.js.map +1 -1
- package/bin/internals/index.d.ts +10 -10
- package/bin/internals/index.js +26 -26
- package/package.json +9 -7
- package/src/LiveMediaSession.ts +24 -20
- package/src/LiveMediaSessionCoordinator.ts +101 -29
- package/src/MediaPlayerSynchronizer.ts +30 -14
- package/src/internals/GroupCoordinatorState.ts +49 -34
- package/src/internals/GroupPlaybackPosition.ts +7 -3
- package/src/internals/GroupPlaybackTrack.ts +2 -2
- package/src/internals/GroupPlaybackTrackData.ts +2 -2
- package/src/internals/GroupTransportState.ts +11 -4
- package/src/internals/consts.ts +4 -0
- package/typedoc.json +10 -0
- package/bin/EphemeralMediaSession.d.ts +0 -102
- package/bin/EphemeralMediaSession.d.ts.map +0 -1
- package/bin/EphemeralMediaSession.js +0 -226
- package/bin/EphemeralMediaSession.js.map +0 -1
- package/bin/EphemeralMediaSessionCoordinator.d.ts +0 -228
- package/bin/EphemeralMediaSessionCoordinator.d.ts.map +0 -1
- package/bin/EphemeralMediaSessionCoordinator.js +0 -396
- package/bin/EphemeralMediaSessionCoordinator.js.map +0 -1
- package/bin/EphemeralMediaSessionCoordinatorSuspension.d.ts +0 -20
- package/bin/EphemeralMediaSessionCoordinatorSuspension.d.ts.map +0 -1
- package/bin/EphemeralMediaSessionCoordinatorSuspension.js +0 -28
- package/bin/EphemeralMediaSessionCoordinatorSuspension.js.map +0 -1
- package/bin/VolumeLimiter.d.ts +0 -70
- package/bin/VolumeLimiter.d.ts.map +0 -1
- package/bin/VolumeLimiter.js +0 -170
- package/bin/VolumeLimiter.js.map +0 -1
- package/src/test/GroupPlaybackPosition.spec.ts +0 -600
- package/src/test/GroupPlaybackTrack.spec.ts +0 -122
- package/src/test/SharedMediaSession.spec.ts +0 -149
- package/src/test/SharedMediaSessionCoordinator.spec.ts +0 -271
- package/src/test/VolumeManager.spec.ts +0 -219
package/bin/VolumeLimiter.js
DELETED
|
@@ -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
|
package/bin/Vol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