@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.
- package/README.md +30 -31
- package/bin/cjs/IMediaPlayer.d.ts.map +1 -0
- package/bin/cjs/IMediaPlayer.js.map +1 -0
- package/bin/{LiveMediaSession.d.ts → cjs/LiveMediaSession.d.ts} +16 -9
- package/bin/cjs/LiveMediaSession.d.ts.map +1 -0
- package/bin/{LiveMediaSession.js → cjs/LiveMediaSession.js} +31 -25
- package/bin/cjs/LiveMediaSession.js.map +1 -0
- package/bin/{LiveMediaSessionCoordinator.d.ts → cjs/LiveMediaSessionCoordinator.d.ts} +57 -13
- package/bin/cjs/LiveMediaSessionCoordinator.d.ts.map +1 -0
- package/bin/{LiveMediaSessionCoordinator.js → cjs/LiveMediaSessionCoordinator.js} +152 -64
- package/bin/cjs/LiveMediaSessionCoordinator.js.map +1 -0
- package/bin/{LiveMediaSessionCoordinatorSuspension.d.ts → cjs/LiveMediaSessionCoordinatorSuspension.d.ts} +1 -1
- package/bin/cjs/LiveMediaSessionCoordinatorSuspension.d.ts.map +1 -0
- package/bin/cjs/LiveMediaSessionCoordinatorSuspension.js.map +1 -0
- package/bin/{MediaPlayerSynchronizer.d.ts → cjs/MediaPlayerSynchronizer.d.ts} +22 -8
- package/bin/cjs/MediaPlayerSynchronizer.d.ts.map +1 -0
- package/bin/{MediaPlayerSynchronizer.js → cjs/MediaPlayerSynchronizer.js} +38 -41
- package/bin/cjs/MediaPlayerSynchronizer.js.map +1 -0
- package/bin/{MediaSessionActionThrottler.d.ts → cjs/MediaSessionActionThrottler.d.ts} +1 -1
- package/bin/cjs/MediaSessionActionThrottler.d.ts.map +1 -0
- package/bin/cjs/MediaSessionActionThrottler.js.map +1 -0
- package/bin/cjs/MediaSessionExtensions.d.ts.map +1 -0
- package/bin/cjs/MediaSessionExtensions.js.map +1 -0
- package/bin/{RepeatedActionThrottler.d.ts → cjs/RepeatedActionThrottler.d.ts} +2 -2
- package/bin/cjs/RepeatedActionThrottler.d.ts.map +1 -0
- package/bin/{RepeatedActionThrottler.js → cjs/RepeatedActionThrottler.js} +2 -2
- package/bin/cjs/RepeatedActionThrottler.js.map +1 -0
- package/bin/{VolumeManager.d.ts → cjs/VolumeManager.d.ts} +6 -6
- package/bin/cjs/VolumeManager.d.ts.map +1 -0
- package/bin/{VolumeManager.js → cjs/VolumeManager.js} +5 -5
- package/bin/cjs/VolumeManager.js.map +1 -0
- package/bin/cjs/index.d.ts +14 -0
- package/bin/cjs/index.d.ts.map +1 -0
- package/bin/{internals → cjs}/index.js +9 -8
- package/bin/cjs/index.js.map +1 -0
- package/bin/{internals → cjs/internals}/GroupCoordinatorState.d.ts +14 -12
- package/bin/cjs/internals/GroupCoordinatorState.d.ts.map +1 -0
- package/bin/{internals → cjs/internals}/GroupCoordinatorState.js +46 -49
- package/bin/cjs/internals/GroupCoordinatorState.js.map +1 -0
- package/bin/{internals → cjs/internals}/GroupPlaybackPosition.d.ts +6 -5
- package/bin/cjs/internals/GroupPlaybackPosition.d.ts.map +1 -0
- package/bin/{internals → cjs/internals}/GroupPlaybackPosition.js +3 -3
- package/bin/cjs/internals/GroupPlaybackPosition.js.map +1 -0
- package/bin/{internals → cjs/internals}/GroupPlaybackRate.d.ts +4 -5
- package/bin/cjs/internals/GroupPlaybackRate.d.ts.map +1 -0
- package/bin/{internals → cjs/internals}/GroupPlaybackRate.js +2 -5
- package/bin/cjs/internals/GroupPlaybackRate.js.map +1 -0
- package/bin/{internals → cjs/internals}/GroupPlaybackTrack.d.ts +5 -6
- package/bin/cjs/internals/GroupPlaybackTrack.d.ts.map +1 -0
- package/bin/{internals → cjs/internals}/GroupPlaybackTrack.js +2 -5
- package/bin/cjs/internals/GroupPlaybackTrack.js.map +1 -0
- package/bin/{internals → cjs/internals}/GroupPlaybackTrackData.d.ts +5 -6
- package/bin/cjs/internals/GroupPlaybackTrackData.d.ts.map +1 -0
- package/bin/{internals → cjs/internals}/GroupPlaybackTrackData.js +4 -7
- package/bin/cjs/internals/GroupPlaybackTrackData.js.map +1 -0
- package/bin/{internals → cjs/internals}/GroupTransportState.d.ts +8 -9
- package/bin/cjs/internals/GroupTransportState.d.ts.map +1 -0
- package/bin/{internals → cjs/internals}/GroupTransportState.js +4 -7
- package/bin/cjs/internals/GroupTransportState.js.map +1 -0
- package/bin/cjs/internals/PriorityTimeInterval.d.ts +33 -0
- package/bin/cjs/internals/PriorityTimeInterval.d.ts.map +1 -0
- package/bin/cjs/internals/PriorityTimeInterval.js +45 -0
- package/bin/cjs/internals/PriorityTimeInterval.js.map +1 -0
- package/bin/cjs/internals/consts.d.ts.map +1 -0
- package/bin/cjs/internals/consts.js.map +1 -0
- package/bin/cjs/internals/errors.d.ts.map +1 -0
- package/bin/cjs/internals/errors.js.map +1 -0
- package/bin/cjs/internals/interfaces.d.ts +23 -0
- package/bin/cjs/internals/interfaces.d.ts.map +1 -0
- package/bin/{internals → cjs/internals}/interfaces.js.map +1 -1
- package/bin/cjs/package.json +1 -0
- package/bin/esm/IMediaPlayer.d.ts +21 -0
- package/bin/esm/IMediaPlayer.d.ts.map +1 -0
- package/bin/esm/IMediaPlayer.js +6 -0
- package/bin/esm/IMediaPlayer.js.map +1 -0
- package/bin/esm/LiveMediaSession.d.ts +97 -0
- package/bin/esm/LiveMediaSession.d.ts.map +1 -0
- package/bin/esm/LiveMediaSession.js +257 -0
- package/bin/esm/LiveMediaSession.js.map +1 -0
- package/bin/esm/LiveMediaSessionCoordinator.d.ts +304 -0
- package/bin/esm/LiveMediaSessionCoordinator.d.ts.map +1 -0
- package/bin/esm/LiveMediaSessionCoordinator.js +556 -0
- package/bin/esm/LiveMediaSessionCoordinator.js.map +1 -0
- package/bin/esm/LiveMediaSessionCoordinatorSuspension.d.ts +20 -0
- package/bin/esm/LiveMediaSessionCoordinatorSuspension.d.ts.map +1 -0
- package/bin/esm/LiveMediaSessionCoordinatorSuspension.js +24 -0
- package/bin/esm/LiveMediaSessionCoordinatorSuspension.js.map +1 -0
- package/bin/esm/MediaPlayerSynchronizer.d.ts +204 -0
- package/bin/esm/MediaPlayerSynchronizer.d.ts.map +1 -0
- package/bin/esm/MediaPlayerSynchronizer.js +570 -0
- package/bin/esm/MediaPlayerSynchronizer.js.map +1 -0
- package/bin/esm/MediaSessionActionThrottler.d.ts +12 -0
- package/bin/esm/MediaSessionActionThrottler.d.ts.map +1 -0
- package/bin/esm/MediaSessionActionThrottler.js +10 -0
- package/bin/esm/MediaSessionActionThrottler.js.map +1 -0
- package/bin/esm/MediaSessionExtensions.d.ts +177 -0
- package/bin/esm/MediaSessionExtensions.d.ts.map +1 -0
- package/bin/esm/MediaSessionExtensions.js +23 -0
- package/bin/esm/MediaSessionExtensions.js.map +1 -0
- package/bin/esm/RepeatedActionThrottler.d.ts +20 -0
- package/bin/esm/RepeatedActionThrottler.d.ts.map +1 -0
- package/bin/esm/RepeatedActionThrottler.js +59 -0
- package/bin/esm/RepeatedActionThrottler.js.map +1 -0
- package/bin/esm/VolumeManager.d.ts +84 -0
- package/bin/esm/VolumeManager.d.ts.map +1 -0
- package/bin/esm/VolumeManager.js +171 -0
- package/bin/esm/VolumeManager.js.map +1 -0
- package/bin/esm/index.d.ts +14 -0
- package/bin/esm/index.d.ts.map +1 -0
- package/bin/esm/index.js +14 -0
- package/bin/esm/index.js.map +1 -0
- package/bin/esm/internals/GroupCoordinatorState.d.ts +110 -0
- package/bin/esm/internals/GroupCoordinatorState.d.ts.map +1 -0
- package/bin/esm/internals/GroupCoordinatorState.js +512 -0
- package/bin/esm/internals/GroupCoordinatorState.js.map +1 -0
- package/bin/esm/internals/GroupPlaybackPosition.d.ts +71 -0
- package/bin/esm/internals/GroupPlaybackPosition.d.ts.map +1 -0
- package/bin/esm/internals/GroupPlaybackPosition.js +166 -0
- package/bin/esm/internals/GroupPlaybackPosition.js.map +1 -0
- package/bin/esm/internals/GroupPlaybackRate.d.ts +38 -0
- package/bin/esm/internals/GroupPlaybackRate.d.ts.map +1 -0
- package/bin/esm/internals/GroupPlaybackRate.js +55 -0
- package/bin/esm/internals/GroupPlaybackRate.js.map +1 -0
- package/bin/esm/internals/GroupPlaybackTrack.d.ts +45 -0
- package/bin/esm/internals/GroupPlaybackTrack.d.ts.map +1 -0
- package/bin/esm/internals/GroupPlaybackTrack.js +118 -0
- package/bin/esm/internals/GroupPlaybackTrack.js.map +1 -0
- package/bin/esm/internals/GroupPlaybackTrackData.d.ts +40 -0
- package/bin/esm/internals/GroupPlaybackTrackData.d.ts.map +1 -0
- package/bin/esm/internals/GroupPlaybackTrackData.js +66 -0
- package/bin/esm/internals/GroupPlaybackTrackData.js.map +1 -0
- package/bin/esm/internals/GroupTransportState.d.ts +52 -0
- package/bin/esm/internals/GroupTransportState.d.ts.map +1 -0
- package/bin/esm/internals/GroupTransportState.js +116 -0
- package/bin/esm/internals/GroupTransportState.js.map +1 -0
- package/bin/esm/internals/PriorityTimeInterval.d.ts +33 -0
- package/bin/esm/internals/PriorityTimeInterval.d.ts.map +1 -0
- package/bin/esm/internals/PriorityTimeInterval.js +41 -0
- package/bin/esm/internals/PriorityTimeInterval.js.map +1 -0
- package/bin/esm/internals/consts.d.ts +83 -0
- package/bin/esm/internals/consts.d.ts.map +1 -0
- package/bin/esm/internals/consts.js +89 -0
- package/bin/esm/internals/consts.js.map +1 -0
- package/bin/esm/internals/errors.d.ts +17 -0
- package/bin/esm/internals/errors.d.ts.map +1 -0
- package/bin/esm/internals/errors.js +29 -0
- package/bin/esm/internals/errors.js.map +1 -0
- package/bin/esm/internals/interfaces.d.ts +23 -0
- package/bin/esm/internals/interfaces.d.ts.map +1 -0
- package/bin/esm/internals/interfaces.js +2 -0
- package/bin/esm/internals/interfaces.js.map +1 -0
- package/package.json +31 -12
- package/src/LiveMediaSession.ts +29 -14
- package/src/LiveMediaSessionCoordinator.ts +149 -37
- package/src/LiveMediaSessionCoordinatorSuspension.ts +1 -1
- package/src/MediaPlayerSynchronizer.ts +26 -11
- package/src/MediaSessionActionThrottler.ts +1 -1
- package/src/RepeatedActionThrottler.ts +2 -2
- package/src/VolumeManager.ts +6 -6
- package/src/index.ts +9 -9
- package/src/internals/GroupCoordinatorState.ts +19 -15
- package/src/internals/GroupPlaybackPosition.ts +9 -9
- package/src/internals/GroupPlaybackRate.ts +4 -4
- package/src/internals/GroupPlaybackTrack.ts +5 -5
- package/src/internals/GroupPlaybackTrackData.ts +5 -5
- package/src/internals/GroupTransportState.ts +8 -8
- package/src/internals/PriorityTimeInterval.ts +76 -0
- package/src/internals/interfaces.ts +15 -1
- package/tsconfig.cjs.json +14 -0
- package/tsconfig.json +65 -74
- package/.nycrc.json +0 -11
- package/bin/IMediaPlayer.d.ts.map +0 -1
- package/bin/IMediaPlayer.js.map +0 -1
- package/bin/LiveMediaSession.d.ts.map +0 -1
- package/bin/LiveMediaSession.js.map +0 -1
- package/bin/LiveMediaSessionCoordinator.d.ts.map +0 -1
- package/bin/LiveMediaSessionCoordinator.js.map +0 -1
- package/bin/LiveMediaSessionCoordinatorSuspension.d.ts.map +0 -1
- package/bin/LiveMediaSessionCoordinatorSuspension.js.map +0 -1
- package/bin/MediaPlayerSynchronizer.d.ts.map +0 -1
- package/bin/MediaPlayerSynchronizer.js.map +0 -1
- package/bin/MediaSessionActionThrottler.d.ts.map +0 -1
- package/bin/MediaSessionActionThrottler.js.map +0 -1
- package/bin/MediaSessionExtensions.d.ts.map +0 -1
- package/bin/MediaSessionExtensions.js.map +0 -1
- package/bin/RepeatedActionThrottler.d.ts.map +0 -1
- package/bin/RepeatedActionThrottler.js.map +0 -1
- package/bin/VolumeManager.d.ts.map +0 -1
- package/bin/VolumeManager.js.map +0 -1
- package/bin/index.d.ts +0 -14
- package/bin/index.d.ts.map +0 -1
- package/bin/index.js +0 -30
- package/bin/index.js.map +0 -1
- package/bin/internals/GroupCoordinatorState.d.ts.map +0 -1
- package/bin/internals/GroupCoordinatorState.js.map +0 -1
- package/bin/internals/GroupPlaybackPosition.d.ts.map +0 -1
- package/bin/internals/GroupPlaybackPosition.js.map +0 -1
- package/bin/internals/GroupPlaybackRate.d.ts.map +0 -1
- package/bin/internals/GroupPlaybackRate.js.map +0 -1
- package/bin/internals/GroupPlaybackTrack.d.ts.map +0 -1
- package/bin/internals/GroupPlaybackTrack.js.map +0 -1
- package/bin/internals/GroupPlaybackTrackData.d.ts.map +0 -1
- package/bin/internals/GroupPlaybackTrackData.js.map +0 -1
- package/bin/internals/GroupTransportState.d.ts.map +0 -1
- package/bin/internals/GroupTransportState.js.map +0 -1
- package/bin/internals/consts.d.ts.map +0 -1
- package/bin/internals/consts.js.map +0 -1
- package/bin/internals/errors.d.ts.map +0 -1
- package/bin/internals/errors.js.map +0 -1
- package/bin/internals/index.d.ts +0 -13
- package/bin/internals/index.d.ts.map +0 -1
- package/bin/internals/index.js.map +0 -1
- package/bin/internals/interfaces.d.ts +0 -10
- package/bin/internals/interfaces.d.ts.map +0 -1
- package/src/internals/index.ts +0 -13
- package/tsconfig.build.json +0 -9
- package/typedoc.json +0 -10
- /package/bin/{IMediaPlayer.d.ts → cjs/IMediaPlayer.d.ts} +0 -0
- /package/bin/{IMediaPlayer.js → cjs/IMediaPlayer.js} +0 -0
- /package/bin/{LiveMediaSessionCoordinatorSuspension.js → cjs/LiveMediaSessionCoordinatorSuspension.js} +0 -0
- /package/bin/{MediaSessionActionThrottler.js → cjs/MediaSessionActionThrottler.js} +0 -0
- /package/bin/{MediaSessionExtensions.d.ts → cjs/MediaSessionExtensions.d.ts} +0 -0
- /package/bin/{MediaSessionExtensions.js → cjs/MediaSessionExtensions.js} +0 -0
- /package/bin/{internals → cjs/internals}/consts.d.ts +0 -0
- /package/bin/{internals → cjs/internals}/consts.js +0 -0
- /package/bin/{internals → cjs/internals}/errors.d.ts +0 -0
- /package/bin/{internals → cjs/internals}/errors.js +0 -0
- /package/bin/{internals → cjs/internals}/interfaces.js +0 -0
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
|
+
* Licensed under the Microsoft Live Share SDK License.
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Suspension object for when group synchronization is suspended for the local user.
|
|
7
|
+
*/
|
|
8
|
+
export interface MediaSessionCoordinatorSuspension {
|
|
9
|
+
/**
|
|
10
|
+
* The wait point that the suspension was created with.
|
|
11
|
+
*
|
|
12
|
+
* @remarks
|
|
13
|
+
* If undefined, the suspension was not created with a wait point.
|
|
14
|
+
*/
|
|
15
|
+
waitPoint?: CoordinationWaitPoint;
|
|
16
|
+
/**
|
|
17
|
+
* Ends the suspension.
|
|
18
|
+
*
|
|
19
|
+
* @param seekTo the timestamp to seek to after the suspension ends.
|
|
20
|
+
* If no value is provided, the local user will return to the group playback position.
|
|
21
|
+
*
|
|
22
|
+
* @remarks
|
|
23
|
+
* If there are other suspensions active, all other suspensions must be ended before group synchronization can resume.
|
|
24
|
+
*/
|
|
25
|
+
end(seekTo?: number): void;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Wait point interface for a suspension.
|
|
29
|
+
*
|
|
30
|
+
* @remarks
|
|
31
|
+
* Used by {@link MediaSessionCoordinatorSuspension} to schedule a suspension at a specific media position.
|
|
32
|
+
*/
|
|
33
|
+
export interface CoordinationWaitPoint {
|
|
34
|
+
/**
|
|
35
|
+
* The position in milliseconds that the suspension should begin.
|
|
36
|
+
*/
|
|
37
|
+
position: number;
|
|
38
|
+
/**
|
|
39
|
+
* Optional. The reason for the suspension.
|
|
40
|
+
*/
|
|
41
|
+
reason?: string;
|
|
42
|
+
/**
|
|
43
|
+
* Optional. The max clients to wait for before a suspension ends.
|
|
44
|
+
*/
|
|
45
|
+
maxClients?: number;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Event types of `LiveMediaSessionCoordinator`.
|
|
49
|
+
*/
|
|
50
|
+
export declare enum MediaSessionCoordinatorEvents {
|
|
51
|
+
/**
|
|
52
|
+
* Event emitted after the coordinator's state changed
|
|
53
|
+
*/
|
|
54
|
+
coordinatorstatechange = "coordinatorstatechange",
|
|
55
|
+
/**
|
|
56
|
+
* Event emitted when an action was triggered.
|
|
57
|
+
*/
|
|
58
|
+
triggeraction = "triggeraction",
|
|
59
|
+
/**
|
|
60
|
+
* Event emitted when an action would have been triggered, but a suspension is active for the local client.
|
|
61
|
+
*/
|
|
62
|
+
triggeractionignored = "triggeractionignored"
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Action types supported for `LiveMediaSession`.
|
|
66
|
+
*
|
|
67
|
+
* @remarks
|
|
68
|
+
* These types extend the default actions supported by the `MediaSession` specification in browsers.
|
|
69
|
+
* These additional actions help with group synchronization.
|
|
70
|
+
*/
|
|
71
|
+
export type ExtendedMediaSessionAction = MediaSessionAction | "settrack" | "ratechange" | "wait" | "catchup" | "datachange" | "blocked";
|
|
72
|
+
/**
|
|
73
|
+
* Extended playback state for `LiveMediaSession`.
|
|
74
|
+
*
|
|
75
|
+
* @remarks
|
|
76
|
+
* These types extend the default state types supported by the `MediaSession` specification in browsers.
|
|
77
|
+
* These additional types help with group synchronization.
|
|
78
|
+
*/
|
|
79
|
+
export type ExtendedMediaSessionPlaybackState = MediaSessionPlaybackState | "suspended" | "waiting" | "ended";
|
|
80
|
+
/**
|
|
81
|
+
* The source of the action for `LiveMediaSession`.
|
|
82
|
+
*
|
|
83
|
+
* @remarks
|
|
84
|
+
* Is `user` when the action was explicitly invoked via the `LiveMediaSessionCoordinator`.
|
|
85
|
+
* Is `system` when the action was invoked via `GroupCoordinatorState` when the local client is out of sync.
|
|
86
|
+
*/
|
|
87
|
+
export type ExtendedMediaSessionActionSource = "user" | "system";
|
|
88
|
+
/**
|
|
89
|
+
* Metadata for `LiveMediaSession`.
|
|
90
|
+
*
|
|
91
|
+
* @remarks
|
|
92
|
+
* These types extend the default session metadata supported by the `MediaSession` specification in browsers.
|
|
93
|
+
* These additional types help with group synchronization.
|
|
94
|
+
*/
|
|
95
|
+
export interface ExtendedMediaMetadata extends MediaMetadata {
|
|
96
|
+
/**
|
|
97
|
+
* A unique identifier for the track (e.g., UUID, URL, etc.)
|
|
98
|
+
*/
|
|
99
|
+
trackIdentifier: string;
|
|
100
|
+
/**
|
|
101
|
+
* Flag indicating whether or not the stream is a live broadcast.
|
|
102
|
+
*/
|
|
103
|
+
liveStream?: boolean;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* The reasons why an action is ignored.
|
|
107
|
+
*
|
|
108
|
+
* @remarks
|
|
109
|
+
* Is `localusersuspended` when the action updated the group state, but ignored locally due to the local client being suspended.
|
|
110
|
+
|
|
111
|
+
*/
|
|
112
|
+
export type ExtendedMediaSessionActionIgnore = "localusersuspended";
|
|
113
|
+
/**
|
|
114
|
+
* Details for emitted actions from `LiveMediaSession`.
|
|
115
|
+
*
|
|
116
|
+
* @remarks
|
|
117
|
+
* These types extend the default event details supported by the `MediaSession` specification in browsers.
|
|
118
|
+
* These additional types help with group synchronization.
|
|
119
|
+
*/
|
|
120
|
+
export interface ExtendedMediaSessionActionDetails {
|
|
121
|
+
/**
|
|
122
|
+
* The action type of this event.
|
|
123
|
+
*/
|
|
124
|
+
action: ExtendedMediaSessionAction;
|
|
125
|
+
/**
|
|
126
|
+
* The source of the action.
|
|
127
|
+
*
|
|
128
|
+
* @remarks
|
|
129
|
+
* Is `user` when the action was explicitly invoked via the `LiveMediaSessionCoordinator`.
|
|
130
|
+
* Is `system` when the action was invoked via `GroupCoordinatorState` when the local client is out of sync.
|
|
131
|
+
*/
|
|
132
|
+
source: ExtendedMediaSessionActionSource;
|
|
133
|
+
/**
|
|
134
|
+
* Unique identifier of the client that triggered this action.
|
|
135
|
+
*/
|
|
136
|
+
clientId: string;
|
|
137
|
+
/**
|
|
138
|
+
* Flag indicating whether or not the action was triggered by the local client.
|
|
139
|
+
*/
|
|
140
|
+
local: boolean;
|
|
141
|
+
/**
|
|
142
|
+
* Flag indicating whether or not this was a fast seek action.
|
|
143
|
+
*/
|
|
144
|
+
fastSeek?: boolean | null;
|
|
145
|
+
/**
|
|
146
|
+
* The offset of the seek.
|
|
147
|
+
*/
|
|
148
|
+
seekOffset?: number | null;
|
|
149
|
+
/**
|
|
150
|
+
* Timestamp of the seek event.
|
|
151
|
+
*/
|
|
152
|
+
seekTime?: number | null;
|
|
153
|
+
/**
|
|
154
|
+
* Updated session metadata that was changed via this action.
|
|
155
|
+
*/
|
|
156
|
+
metadata?: ExtendedMediaMetadata | null;
|
|
157
|
+
/**
|
|
158
|
+
* Suspension associated with this action.
|
|
159
|
+
*/
|
|
160
|
+
suspension?: MediaSessionCoordinatorSuspension | null;
|
|
161
|
+
/**
|
|
162
|
+
* Custom data associated with this action.
|
|
163
|
+
*/
|
|
164
|
+
data?: object | null;
|
|
165
|
+
/**
|
|
166
|
+
* Reason an action is ignored by the local client, undefined if not ignored.
|
|
167
|
+
*/
|
|
168
|
+
ignoreReason?: ExtendedMediaSessionActionIgnore | null;
|
|
169
|
+
playbackRate?: number | null;
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* Handler for `LiveMediaSession` actions.
|
|
173
|
+
*/
|
|
174
|
+
export interface ExtendedMediaSessionActionHandler {
|
|
175
|
+
(details: ExtendedMediaSessionActionDetails): void;
|
|
176
|
+
}
|
|
177
|
+
//# sourceMappingURL=MediaSessionExtensions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MediaSessionExtensions.d.ts","sourceRoot":"","sources":["../../src/MediaSessionExtensions.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;GAEG;AACH,MAAM,WAAW,iCAAiC;IAC9C;;;;;OAKG;IACH,SAAS,CAAC,EAAE,qBAAqB,CAAC;IAClC;;;;;;;;OAQG;IACH,GAAG,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC9B;AAED;;;;;GAKG;AACH,MAAM,WAAW,qBAAqB;IAClC;;OAEG;IAC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,EAAE,qBAAqB,GAAG,IAAI,CAAC;IACxC;;OAEG;IACH,UAAU,CAAC,EAAE,iCAAiC,GAAG,IAAI,CAAC;IACtD;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB;;OAEG;IACH,YAAY,CAAC,EAAE,gCAAgC,GAAG,IAAI,CAAC;IAEvD,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAChC;AAED;;GAEG;AACH,MAAM,WAAW,iCAAiC;IAC9C,CAAC,OAAO,EAAE,iCAAiC,GAAG,IAAI,CAAC;CACtD"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
|
+
* Licensed under the Microsoft Live Share SDK License.
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Event types of `LiveMediaSessionCoordinator`.
|
|
7
|
+
*/
|
|
8
|
+
export var MediaSessionCoordinatorEvents;
|
|
9
|
+
(function (MediaSessionCoordinatorEvents) {
|
|
10
|
+
/**
|
|
11
|
+
* Event emitted after the coordinator's state changed
|
|
12
|
+
*/
|
|
13
|
+
MediaSessionCoordinatorEvents["coordinatorstatechange"] = "coordinatorstatechange";
|
|
14
|
+
/**
|
|
15
|
+
* Event emitted when an action was triggered.
|
|
16
|
+
*/
|
|
17
|
+
MediaSessionCoordinatorEvents["triggeraction"] = "triggeraction";
|
|
18
|
+
/**
|
|
19
|
+
* Event emitted when an action would have been triggered, but a suspension is active for the local client.
|
|
20
|
+
*/
|
|
21
|
+
MediaSessionCoordinatorEvents["triggeractionignored"] = "triggeractionignored";
|
|
22
|
+
})(MediaSessionCoordinatorEvents || (MediaSessionCoordinatorEvents = {}));
|
|
23
|
+
//# sourceMappingURL=MediaSessionExtensions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MediaSessionExtensions.js","sourceRoot":"","sources":["../../src/MediaSessionExtensions.ts"],"names":[],"mappings":"AAAA;;;GAGG;AA8CH;;GAEG;AACH,MAAM,CAAN,IAAY,6BAaX;AAbD,WAAY,6BAA6B;IACrC;;OAEG;IACH,kFAAiD,CAAA;IACjD;;OAEG;IACH,gEAA+B,CAAA;IAC/B;;OAEG;IACH,8EAA6C,CAAA;AACjD,CAAC,EAbW,6BAA6B,KAA7B,6BAA6B,QAaxC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
|
+
* Licensed under the Microsoft Live Share SDK License.
|
|
4
|
+
*/
|
|
5
|
+
import { MediaSessionActionThrottler } from "./MediaSessionActionThrottler.js";
|
|
6
|
+
import { ExtendedMediaSessionActionDetails } from "./MediaSessionExtensions.js";
|
|
7
|
+
/**
|
|
8
|
+
* A Throttler that passes through all actions but will only let an action be repeated once every 2 seconds.
|
|
9
|
+
*/
|
|
10
|
+
export declare class RepeatedActionThrottler extends MediaSessionActionThrottler {
|
|
11
|
+
private static FILTERED_ACTIONS;
|
|
12
|
+
private _repeatInterval;
|
|
13
|
+
private _lastActionSentTime?;
|
|
14
|
+
private _lastActionSent?;
|
|
15
|
+
get repeatInterval(): number;
|
|
16
|
+
set repeatInterval(value: number);
|
|
17
|
+
throttled(details: MediaSessionActionDetails | ExtendedMediaSessionActionDetails, handler?: MediaSessionActionHandler): void;
|
|
18
|
+
private getChangeKey;
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=RepeatedActionThrottler.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RepeatedActionThrottler.d.ts","sourceRoot":"","sources":["../../src/RepeatedActionThrottler.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,2BAA2B,EAAE,MAAM,kCAAkC,CAAC;AAC/E,OAAO,EACH,iCAAiC,EAEpC,MAAM,6BAA6B,CAAC;AAErC;;GAEG;AACH,qBAAa,uBAAwB,SAAQ,2BAA2B;IACpE,OAAO,CAAC,MAAM,CAAC,gBAAgB,CAK7B;IACF,OAAO,CAAC,eAAe,CAA0B;IACjD,OAAO,CAAC,mBAAmB,CAAC,CAAS;IACrC,OAAO,CAAC,eAAe,CAAC,CAAS;IAEjC,IAAW,cAAc,IAAI,MAAM,CAElC;IAED,IAAW,cAAc,CAAC,KAAK,EAAE,MAAM,EAEtC;IAEM,SAAS,CACZ,OAAO,EAAE,yBAAyB,GAAG,iCAAiC,EACtE,OAAO,CAAC,EAAE,yBAAyB,GACpC,IAAI;IA4BP,OAAO,CAAC,YAAY;CAUvB"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
|
+
* Licensed under the Microsoft Live Share SDK License.
|
|
4
|
+
*/
|
|
5
|
+
import { TimeInterval } from "@microsoft/live-share";
|
|
6
|
+
import { MediaSessionActionThrottler } from "./MediaSessionActionThrottler.js";
|
|
7
|
+
/**
|
|
8
|
+
* A Throttler that passes through all actions but will only let an action be repeated once every 2 seconds.
|
|
9
|
+
*/
|
|
10
|
+
export class RepeatedActionThrottler extends MediaSessionActionThrottler {
|
|
11
|
+
constructor() {
|
|
12
|
+
super(...arguments);
|
|
13
|
+
this._repeatInterval = new TimeInterval(2000);
|
|
14
|
+
}
|
|
15
|
+
get repeatInterval() {
|
|
16
|
+
return this._repeatInterval.seconds;
|
|
17
|
+
}
|
|
18
|
+
set repeatInterval(value) {
|
|
19
|
+
this._repeatInterval.seconds = value;
|
|
20
|
+
}
|
|
21
|
+
throttled(details, handler) {
|
|
22
|
+
if (handler) {
|
|
23
|
+
if (RepeatedActionThrottler.FILTERED_ACTIONS.indexOf(details.action) >= 0) {
|
|
24
|
+
const changeKey = this.getChangeKey(details);
|
|
25
|
+
const now = new Date().getTime();
|
|
26
|
+
if (this._lastActionSent && changeKey == this._lastActionSent) {
|
|
27
|
+
if (now - this._lastActionSentTime >=
|
|
28
|
+
this._repeatInterval.milliseconds) {
|
|
29
|
+
handler(details);
|
|
30
|
+
this._lastActionSentTime = now;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
handler(details);
|
|
35
|
+
this._lastActionSent = changeKey;
|
|
36
|
+
this._lastActionSentTime = now;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
handler(details);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
getChangeKey(details) {
|
|
45
|
+
switch (details.action) {
|
|
46
|
+
case "seekto":
|
|
47
|
+
return `seekto:${details.seekTime}`;
|
|
48
|
+
default:
|
|
49
|
+
return details.action;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
RepeatedActionThrottler.FILTERED_ACTIONS = [
|
|
54
|
+
"play",
|
|
55
|
+
"pause",
|
|
56
|
+
"seekto",
|
|
57
|
+
"catchup",
|
|
58
|
+
];
|
|
59
|
+
//# sourceMappingURL=RepeatedActionThrottler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RepeatedActionThrottler.js","sourceRoot":"","sources":["../../src/RepeatedActionThrottler.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACrD,OAAO,EAAE,2BAA2B,EAAE,MAAM,kCAAkC,CAAC;AAM/E;;GAEG;AACH,MAAM,OAAO,uBAAwB,SAAQ,2BAA2B;IAAxE;;QAOY,oBAAe,GAAG,IAAI,YAAY,CAAC,IAAI,CAAC,CAAC;IAqDrD,CAAC;IAjDG,IAAW,cAAc;QACrB,OAAO,IAAI,CAAC,eAAe,CAAC,OAAO,CAAC;IACxC,CAAC;IAED,IAAW,cAAc,CAAC,KAAa;QACnC,IAAI,CAAC,eAAe,CAAC,OAAO,GAAG,KAAK,CAAC;IACzC,CAAC;IAEM,SAAS,CACZ,OAAsE,EACtE,OAAmC;Q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
+
*/
|
|
5
|
+
import { IMediaPlayer } from "./IMediaPlayer.js";
|
|
6
|
+
export declare enum LimitLevelType {
|
|
7
|
+
fixed = 0,
|
|
8
|
+
percentage = 1
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Smooth audio level changes when volume is modified, or if volume limiting has started/ended.
|
|
12
|
+
*/
|
|
13
|
+
export declare class VolumeManager {
|
|
14
|
+
private readonly _player;
|
|
15
|
+
private readonly _volumeChangeDuration;
|
|
16
|
+
private _volume;
|
|
17
|
+
private _isLimiting;
|
|
18
|
+
private _limitLevel;
|
|
19
|
+
private _limitLevelType;
|
|
20
|
+
private _startTime;
|
|
21
|
+
private _startVolume;
|
|
22
|
+
private _running;
|
|
23
|
+
constructor(player: IMediaPlayer);
|
|
24
|
+
/**
|
|
25
|
+
* The selected volume.
|
|
26
|
+
*
|
|
27
|
+
* @remarks
|
|
28
|
+
* Expressed as a value between 0.0 and 1.0. The default value is 1.0.
|
|
29
|
+
* Can be used for things like volume sliders.
|
|
30
|
+
*
|
|
31
|
+
* Does not return the current volume if limiting is enabled, but the desired volume.
|
|
32
|
+
*/
|
|
33
|
+
get volume(): number;
|
|
34
|
+
set volume(value: number);
|
|
35
|
+
/**
|
|
36
|
+
* Target level to lower volume to.
|
|
37
|
+
*
|
|
38
|
+
* @remarks
|
|
39
|
+
* Expressed as a value between 0.0 and 1.0. The value is applied based upon the configured
|
|
40
|
+
* @see LimitLevelType. The default value is 0.1.
|
|
41
|
+
*
|
|
42
|
+
* For a level type of @see LimitLevelType.fixed the value is the exact level the volume will be
|
|
43
|
+
* lowered to. The default value of 0.1 would cause the volume to be lowered to 0.1.
|
|
44
|
+
*
|
|
45
|
+
* For a level type of @see LimitLevelType.percentage the value is the percentage by which the volume
|
|
46
|
+
* level should be lowered to. The default value of 0.1 would cause the volume to be lowered
|
|
47
|
+
* to 10% of its starting value.
|
|
48
|
+
*/
|
|
49
|
+
get limitLevel(): number;
|
|
50
|
+
set limitLevel(value: number);
|
|
51
|
+
/**
|
|
52
|
+
* The type of level represented by the `limitLevel` property.
|
|
53
|
+
*/
|
|
54
|
+
get limitLevelType(): LimitLevelType;
|
|
55
|
+
set limitLevelType(value: LimitLevelType);
|
|
56
|
+
/**
|
|
57
|
+
* Amount of time, in seconds, it should take to change the volume up or down to the desired level.
|
|
58
|
+
*
|
|
59
|
+
* @remarks
|
|
60
|
+
* Default `volumeChangeDuration` is 0.5 seconds.
|
|
61
|
+
*/
|
|
62
|
+
get volumeChangeDuration(): number;
|
|
63
|
+
set volumeChangeDuration(value: number);
|
|
64
|
+
/**
|
|
65
|
+
* Whether or not volume limiting is currently enabled.
|
|
66
|
+
*/
|
|
67
|
+
get isLimiting(): boolean;
|
|
68
|
+
/**
|
|
69
|
+
* Limits volume based on `limitLevel` and `limitLevelType` properties.
|
|
70
|
+
* @see limitLevel
|
|
71
|
+
* @see limitLevelType
|
|
72
|
+
*/
|
|
73
|
+
startLimiting(): void;
|
|
74
|
+
/**
|
|
75
|
+
* Disables volume limit.
|
|
76
|
+
*/
|
|
77
|
+
stopLimiting(): void;
|
|
78
|
+
private startAdjusting;
|
|
79
|
+
private scheduleAnimationFrame;
|
|
80
|
+
private computeInterpolatedVolume;
|
|
81
|
+
private computeTargetVolume;
|
|
82
|
+
private millisSinceVolumeChangeStart;
|
|
83
|
+
}
|
|
84
|
+
//# sourceMappingURL=VolumeManager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"VolumeManager.d.ts","sourceRoot":"","sources":["../../src/VolumeManager.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEjD,oBAAY,cAAc;IACtB,KAAK,IAAA;IACL,UAAU,IAAA;CACb;AAED;;GAEG;AACH,qBAAa,aAAa;IACtB,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAe;IACvC,OAAO,CAAC,QAAQ,CAAC,qBAAqB,CAAyB;IAG/D,OAAO,CAAC,OAAO,CAAO;IACtB,OAAO,CAAC,WAAW,CAAS;IAC5B,OAAO,CAAC,WAAW,CAAO;IAC1B,OAAO,CAAC,eAAe,CAAwC;IAC/D,OAAO,CAAC,UAAU,CAAK;IACvB,OAAO,CAAC,YAAY,CAAK;IACzB,OAAO,CAAC,QAAQ,CAAS;gBAEb,MAAM,EAAE,YAAY;IAKhC;;;;;;;;OAQG;IACH,IAAW,MAAM,IAAI,MAAM,CAE1B;IAED,IAAW,MAAM,CAAC,KAAK,EAAE,MAAM,EAS9B;IAED;;;;;;;;;;;;;OAaG;IACH,IAAW,UAAU,IAAI,MAAM,CAE9B;IAED,IAAW,UAAU,CAAC,KAAK,EAAE,MAAM,EAQlC;IAED;;OAEG;IACH,IAAW,cAAc,IAAI,cAAc,CAE1C;IAED,IAAW,cAAc,CAAC,KAAK,EAAE,cAAc,EAE9C;IAED;;;;;OAKG;IACH,IAAW,oBAAoB,IAAI,MAAM,CAExC;IAED,IAAW,oBAAoB,CAAC,KAAK,EAAE,MAAM,EAE5C;IAED;;OAEG;IACH,IAAW,UAAU,IAAI,OAAO,CAE/B;IAED;;;;OAIG;IACI,aAAa,IAAI,IAAI;IAK5B;;OAEG;IACI,YAAY,IAAI,IAAI;IAK3B,OAAO,CAAC,cAAc;IAuBtB,OAAO,CAAC,sBAAsB;IAW9B,OAAO,CAAC,yBAAyB;IASjC,OAAO,CAAC,mBAAmB;IAgB3B,OAAO,CAAC,4BAA4B;CAIvC"}
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
|
+
* Licensed under the Microsoft Live Share SDK License.
|
|
4
|
+
*/
|
|
5
|
+
import { TimeInterval } from "@microsoft/live-share";
|
|
6
|
+
export var LimitLevelType;
|
|
7
|
+
(function (LimitLevelType) {
|
|
8
|
+
LimitLevelType[LimitLevelType["fixed"] = 0] = "fixed";
|
|
9
|
+
LimitLevelType[LimitLevelType["percentage"] = 1] = "percentage";
|
|
10
|
+
})(LimitLevelType || (LimitLevelType = {}));
|
|
11
|
+
/**
|
|
12
|
+
* Smooth audio level changes when volume is modified, or if volume limiting has started/ended.
|
|
13
|
+
*/
|
|
14
|
+
export class VolumeManager {
|
|
15
|
+
constructor(player) {
|
|
16
|
+
this._volumeChangeDuration = new TimeInterval(500);
|
|
17
|
+
// defaults to player volume
|
|
18
|
+
this._volume = 0.0;
|
|
19
|
+
this._isLimiting = false;
|
|
20
|
+
this._limitLevel = 0.1;
|
|
21
|
+
this._limitLevelType = LimitLevelType.fixed;
|
|
22
|
+
this._startTime = 0;
|
|
23
|
+
this._startVolume = 0;
|
|
24
|
+
this._running = false;
|
|
25
|
+
this._player = player;
|
|
26
|
+
this._volume = this._player.volume;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* The selected volume.
|
|
30
|
+
*
|
|
31
|
+
* @remarks
|
|
32
|
+
* Expressed as a value between 0.0 and 1.0. The default value is 1.0.
|
|
33
|
+
* Can be used for things like volume sliders.
|
|
34
|
+
*
|
|
35
|
+
* Does not return the current volume if limiting is enabled, but the desired volume.
|
|
36
|
+
*/
|
|
37
|
+
get volume() {
|
|
38
|
+
return this._volume;
|
|
39
|
+
}
|
|
40
|
+
set volume(value) {
|
|
41
|
+
if (value < 0 || value > 1.0) {
|
|
42
|
+
throw new Error(`VolumeManager: cannot set volume to ${value}. Level must be between 0.0 and 1.0.`);
|
|
43
|
+
}
|
|
44
|
+
this._volume = value;
|
|
45
|
+
this.startAdjusting();
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Target level to lower volume to.
|
|
49
|
+
*
|
|
50
|
+
* @remarks
|
|
51
|
+
* Expressed as a value between 0.0 and 1.0. The value is applied based upon the configured
|
|
52
|
+
* @see LimitLevelType. The default value is 0.1.
|
|
53
|
+
*
|
|
54
|
+
* For a level type of @see LimitLevelType.fixed the value is the exact level the volume will be
|
|
55
|
+
* lowered to. The default value of 0.1 would cause the volume to be lowered to 0.1.
|
|
56
|
+
*
|
|
57
|
+
* For a level type of @see LimitLevelType.percentage the value is the percentage by which the volume
|
|
58
|
+
* level should be lowered to. The default value of 0.1 would cause the volume to be lowered
|
|
59
|
+
* to 10% of its starting value.
|
|
60
|
+
*/
|
|
61
|
+
get limitLevel() {
|
|
62
|
+
return this._limitLevel;
|
|
63
|
+
}
|
|
64
|
+
set limitLevel(value) {
|
|
65
|
+
if (value < 0 || value > 1.0) {
|
|
66
|
+
throw new Error(`VolumeManager: cannot set level to ${value}. Level must be between 0.0 and 1.0.`);
|
|
67
|
+
}
|
|
68
|
+
this._limitLevel = value;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* The type of level represented by the `limitLevel` property.
|
|
72
|
+
*/
|
|
73
|
+
get limitLevelType() {
|
|
74
|
+
return this._limitLevelType;
|
|
75
|
+
}
|
|
76
|
+
set limitLevelType(value) {
|
|
77
|
+
this._limitLevelType = value;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Amount of time, in seconds, it should take to change the volume up or down to the desired level.
|
|
81
|
+
*
|
|
82
|
+
* @remarks
|
|
83
|
+
* Default `volumeChangeDuration` is 0.5 seconds.
|
|
84
|
+
*/
|
|
85
|
+
get volumeChangeDuration() {
|
|
86
|
+
return this._volumeChangeDuration.seconds;
|
|
87
|
+
}
|
|
88
|
+
set volumeChangeDuration(value) {
|
|
89
|
+
this._volumeChangeDuration.seconds = Math.abs(value);
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Whether or not volume limiting is currently enabled.
|
|
93
|
+
*/
|
|
94
|
+
get isLimiting() {
|
|
95
|
+
return this._isLimiting;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Limits volume based on `limitLevel` and `limitLevelType` properties.
|
|
99
|
+
* @see limitLevel
|
|
100
|
+
* @see limitLevelType
|
|
101
|
+
*/
|
|
102
|
+
startLimiting() {
|
|
103
|
+
this._isLimiting = true;
|
|
104
|
+
this.startAdjusting();
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Disables volume limit.
|
|
108
|
+
*/
|
|
109
|
+
stopLimiting() {
|
|
110
|
+
this._isLimiting = false;
|
|
111
|
+
this.startAdjusting();
|
|
112
|
+
}
|
|
113
|
+
startAdjusting() {
|
|
114
|
+
const adjustVolume = () => {
|
|
115
|
+
// Schedule next animation frame if volume change not finished
|
|
116
|
+
if (this.millisSinceVolumeChangeStart() <=
|
|
117
|
+
this._volumeChangeDuration.milliseconds) {
|
|
118
|
+
this._player.volume = this.computeInterpolatedVolume();
|
|
119
|
+
this.scheduleAnimationFrame(adjustVolume);
|
|
120
|
+
}
|
|
121
|
+
else {
|
|
122
|
+
this._player.volume = this.computeTargetVolume();
|
|
123
|
+
this._running = false;
|
|
124
|
+
}
|
|
125
|
+
};
|
|
126
|
+
this._startTime = new Date().getTime();
|
|
127
|
+
this._startVolume = this._player.volume;
|
|
128
|
+
if (!this._running) {
|
|
129
|
+
this._running = true;
|
|
130
|
+
this.scheduleAnimationFrame(adjustVolume);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
scheduleAnimationFrame(callback) {
|
|
134
|
+
if (typeof requestAnimationFrame == "function") {
|
|
135
|
+
requestAnimationFrame(callback);
|
|
136
|
+
}
|
|
137
|
+
else {
|
|
138
|
+
setTimeout(callback, Math.min(this._volumeChangeDuration.milliseconds / 25, 20));
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
computeInterpolatedVolume() {
|
|
142
|
+
const volumeChangeMillis = this._volumeChangeDuration.milliseconds;
|
|
143
|
+
const volumeDifference = this.computeTargetVolume() - this._startVolume;
|
|
144
|
+
const adjustmentFromStart = (volumeDifference / volumeChangeMillis) *
|
|
145
|
+
this.millisSinceVolumeChangeStart();
|
|
146
|
+
return this._startVolume + adjustmentFromStart;
|
|
147
|
+
}
|
|
148
|
+
computeTargetVolume() {
|
|
149
|
+
if (this._limitLevelType == LimitLevelType.percentage) {
|
|
150
|
+
if (this._isLimiting) {
|
|
151
|
+
return this._volume * this._limitLevel;
|
|
152
|
+
}
|
|
153
|
+
else {
|
|
154
|
+
return this._volume;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
else {
|
|
158
|
+
if (this._isLimiting && this._volume > this._limitLevel) {
|
|
159
|
+
return this._limitLevel;
|
|
160
|
+
}
|
|
161
|
+
else {
|
|
162
|
+
return this._volume;
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
millisSinceVolumeChangeStart() {
|
|
167
|
+
const now = new Date().getTime();
|
|
168
|
+
return now - this._startTime;
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
//# sourceMappingURL=VolumeManager.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"VolumeManager.js","sourceRoot":"","sources":["../../src/VolumeManager.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAGrD,MAAM,CAAN,IAAY,cAGX;AAHD,WAAY,cAAc;IACtB,qDAAK,CAAA;IACL,+DAAU,CAAA;AACd,CAAC,EAHW,cAAc,KAAd,cAAc,QAGzB;AAED;;GAEG;AACH,MAAM,OAAO,aAAa;IAatB,YAAY,MAAoB;QAXf,0BAAqB,GAAG,IAAI,YAAY,CAAC,GAAG,CAAC,CAAC;QAE/D,4BAA4B;QACpB,YAAO,GAAG,GAAG,CAAC;QACd,gBAAW,GAAG,KAAK,CAAC;QACpB,gBAAW,GAAG,GAAG,CAAC;QAClB,oBAAe,GAAmB,cAAc,CAAC,KAAK,CAAC;QACvD,eAAU,GAAG,CAAC,CAAC;QACf,iBAAY,GAAG,CAAC,CAAC;QACjB,aAAQ,GAAG,KAAK,CAAC;QAGrB,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;QACtB,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC;IACvC,CAA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AAI,CAAC,qBAAqB,CAAC,YAAY,CAAC;QACnE,MAAM,gBAAgB,GAAG,IAAI,CAAC,mBAAmB,EAAE,GAAG,IAAI,CAAC,YAAY,CAAC;QACxE,MAAM,mBAAmB,GACrB,CAAC,gBAAgB,GAAG,kBAAkB,CAAC;YACvC,IAAI,CAAC,4BAA4B,EAAE,CAAC;QACxC,OAAO,IAAI,CAAC,YAAY,GAAG,mBAAmB,CAAC;IACnD,CAAC;IAEO,mBAAmB;QACvB,IAAI,IAAI,CAAC,eAAe,IAAI,cAAc,CAAC,UAAU,EAAE,CAAC;YACpD,IAAI,IAAI,CAAC,WAAW,EAAE,CAAC;gBACnB,OAAO,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,WAAW,CAAC;YAC3C,CAAC;iBAAM,CAAC;gBACJ,OAAO,IAAI,CAAC,OAAO,CAAC;YACxB,CAAC;QACL,CAAC;aAAM,CAAC;YACJ,IAAI,IAAI,CAAC,WAAW,IAAI,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,WAAW,EAAE,CAAC;gBACtD,OAAO,IAAI,CAAC,WAAW,CAAC;YAC5B,CAAC;iBAAM,CAAC;gBACJ,OAAO,IAAI,CAAC,OAAO,CAAC;YACxB,CAAC;QACL,CAAC;IACL,CAAC;IAEO,4BAA4B;QAChC,MAAM,GAAG,GAAG,IAAI,IAAI,EAAE,CAAC,OAAO,EAAE,CAAC;QACjC,OAAO,GAAG,GAAG,IAAI,CAAC,UAAU,CAAC;IACjC,CAAC;CACJ"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
|
+
* Licensed under the Microsoft Live Share SDK License.
|
|
4
|
+
*/
|
|
5
|
+
export * from "./LiveMediaSession.js";
|
|
6
|
+
export * from "./LiveMediaSessionCoordinator.js";
|
|
7
|
+
export * from "./LiveMediaSessionCoordinatorSuspension.js";
|
|
8
|
+
export * from "./IMediaPlayer.js";
|
|
9
|
+
export * from "./MediaPlayerSynchronizer.js";
|
|
10
|
+
export * from "./MediaSessionActionThrottler.js";
|
|
11
|
+
export * from "./MediaSessionExtensions.js";
|
|
12
|
+
export * from "./RepeatedActionThrottler.js";
|
|
13
|
+
export * from "./VolumeManager.js";
|
|
14
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,cAAc,uBAAuB,CAAC;AACtC,cAAc,kCAAkC,CAAC;AACjD,cAAc,4CAA4C,CAAC;AAC3D,cAAc,mBAAmB,CAAC;AAClC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,kCAAkC,CAAC;AACjD,cAAc,6BAA6B,CAAC;AAC5C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,oBAAoB,CAAC"}
|
package/bin/esm/index.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
|
+
* Licensed under the Microsoft Live Share SDK License.
|
|
4
|
+
*/
|
|
5
|
+
export * from "./LiveMediaSession.js";
|
|
6
|
+
export * from "./LiveMediaSessionCoordinator.js";
|
|
7
|
+
export * from "./LiveMediaSessionCoordinatorSuspension.js";
|
|
8
|
+
export * from "./IMediaPlayer.js";
|
|
9
|
+
export * from "./MediaPlayerSynchronizer.js";
|
|
10
|
+
export * from "./MediaSessionActionThrottler.js";
|
|
11
|
+
export * from "./MediaSessionExtensions.js";
|
|
12
|
+
export * from "./RepeatedActionThrottler.js";
|
|
13
|
+
export * from "./VolumeManager.js";
|
|
14
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,cAAc,uBAAuB,CAAC;AACtC,cAAc,kCAAkC,CAAC;AACjD,cAAc,4CAA4C,CAAC;AAC3D,cAAc,mBAAmB,CAAC;AAClC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,kCAAkC,CAAC;AACjD,cAAc,6BAA6B,CAAC;AAC5C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,oBAAoB,CAAC"}
|