@microsoft/live-share-media 1.2.2 → 1.3.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.
- package/.nycrc.json +10 -10
- package/LICENSE +90 -90
- package/README.md +135 -135
- package/bin/LiveMediaSession.d.ts.map +1 -1
- package/bin/LiveMediaSession.js +4 -6
- package/bin/LiveMediaSession.js.map +1 -1
- package/bin/LiveMediaSessionCoordinator.d.ts +4 -3
- package/bin/LiveMediaSessionCoordinator.d.ts.map +1 -1
- package/bin/LiveMediaSessionCoordinator.js +56 -69
- package/bin/LiveMediaSessionCoordinator.js.map +1 -1
- package/bin/MediaPlayerSynchronizer.d.ts +12 -0
- package/bin/MediaPlayerSynchronizer.d.ts.map +1 -1
- package/bin/MediaPlayerSynchronizer.js +26 -6
- package/bin/MediaPlayerSynchronizer.js.map +1 -1
- package/bin/MediaSessionExtensions.d.ts +0 -4
- package/bin/MediaSessionExtensions.d.ts.map +1 -1
- package/bin/MediaSessionExtensions.js.map +1 -1
- package/bin/internals/GroupCoordinatorState.d.ts.map +1 -1
- package/bin/internals/GroupCoordinatorState.js +1 -1
- package/bin/internals/GroupCoordinatorState.js.map +1 -1
- package/bin/internals/consts.d.ts +2 -2
- package/bin/internals/consts.d.ts.map +1 -1
- package/bin/internals/consts.js +2 -2
- package/bin/internals/consts.js.map +1 -1
- package/bin/internals/errors.d.ts +17 -0
- package/bin/internals/errors.d.ts.map +1 -0
- package/bin/internals/errors.js +34 -0
- package/bin/internals/errors.js.map +1 -0
- package/bin/internals/index.d.ts +1 -0
- package/bin/internals/index.d.ts.map +1 -1
- package/bin/internals/index.js +1 -0
- package/bin/internals/index.js.map +1 -1
- package/package.json +45 -45
- package/src/IMediaPlayer.ts +29 -29
- package/src/LiveMediaSession.ts +337 -334
- package/src/LiveMediaSessionCoordinator.ts +711 -671
- package/src/LiveMediaSessionCoordinatorSuspension.ts +39 -39
- package/src/MediaPlayerSynchronizer.ts +714 -690
- package/src/MediaSessionActionThrottler.ts +19 -19
- package/src/MediaSessionExtensions.ts +182 -187
- package/src/RepeatedActionThrottler.ts +76 -76
- package/src/VolumeManager.ts +200 -200
- package/src/index.ts +14 -14
- package/src/internals/GroupCoordinatorState.ts +685 -683
- package/src/internals/GroupPlaybackPosition.ts +228 -228
- package/src/internals/GroupPlaybackTrack.ts +182 -182
- package/src/internals/GroupPlaybackTrackData.ts +104 -104
- package/src/internals/GroupTransportState.ts +170 -170
- package/src/internals/consts.ts +103 -102
- package/src/internals/errors.ts +42 -0
- package/src/internals/index.ts +12 -11
- package/tsconfig.build.json +8 -8
- package/tsconfig.json +76 -76
- package/typedoc.json +10 -10
|
@@ -1,170 +1,170 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
|
-
* Licensed under the Microsoft Live Share SDK License.
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
import { ILiveEvent, LiveShareRuntime } from "@microsoft/live-share";
|
|
7
|
-
import EventEmitter from "events";
|
|
8
|
-
import { IMediaPlayerState } from "../LiveMediaSessionCoordinator";
|
|
9
|
-
import {
|
|
10
|
-
ExtendedMediaSessionPlaybackState,
|
|
11
|
-
ExtendedMediaSessionAction,
|
|
12
|
-
ExtendedMediaSessionActionSource,
|
|
13
|
-
} from "../MediaSessionExtensions";
|
|
14
|
-
import {
|
|
15
|
-
GroupPlaybackTrack,
|
|
16
|
-
GroupPlaybackTrackEvents,
|
|
17
|
-
} from "./GroupPlaybackTrack";
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* @hidden
|
|
21
|
-
*/
|
|
22
|
-
export interface ITransportState {
|
|
23
|
-
playbackState: ExtendedMediaSessionPlaybackState;
|
|
24
|
-
startPosition: number;
|
|
25
|
-
timestamp: number;
|
|
26
|
-
clientId: string;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* @hidden
|
|
31
|
-
*/
|
|
32
|
-
export enum GroupTransportStateEvents {
|
|
33
|
-
transportStateChange = "transportStateChange",
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* @hidden
|
|
38
|
-
*/
|
|
39
|
-
export interface ITransportStateChangeEvent extends ILiveEvent {
|
|
40
|
-
action: ExtendedMediaSessionAction;
|
|
41
|
-
seekTime?: number;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* @hidden
|
|
46
|
-
*/
|
|
47
|
-
export class GroupTransportState extends EventEmitter {
|
|
48
|
-
private readonly _getMediaPlayerState: () => IMediaPlayerState;
|
|
49
|
-
private _track: GroupPlaybackTrack;
|
|
50
|
-
private readonly _liveRuntime: LiveShareRuntime;
|
|
51
|
-
private _current: ITransportState;
|
|
52
|
-
|
|
53
|
-
constructor(
|
|
54
|
-
track: GroupPlaybackTrack,
|
|
55
|
-
getMediaPlayerState: () => IMediaPlayerState,
|
|
56
|
-
liveRuntime: LiveShareRuntime
|
|
57
|
-
) {
|
|
58
|
-
super();
|
|
59
|
-
this._liveRuntime = liveRuntime;
|
|
60
|
-
this._getMediaPlayerState = getMediaPlayerState;
|
|
61
|
-
this._track = track;
|
|
62
|
-
this._current = {
|
|
63
|
-
playbackState: "none",
|
|
64
|
-
startPosition: 0.0,
|
|
65
|
-
timestamp: 0,
|
|
66
|
-
clientId: "",
|
|
67
|
-
};
|
|
68
|
-
|
|
69
|
-
// Listen for track changes
|
|
70
|
-
this._track.on(GroupPlaybackTrackEvents.trackChange, () => {
|
|
71
|
-
// Track changed so reset state to stopped ad position 0.0
|
|
72
|
-
this._current = {
|
|
73
|
-
playbackState: "none",
|
|
74
|
-
startPosition: 0.0,
|
|
75
|
-
timestamp: this._track.current.timestamp,
|
|
76
|
-
clientId: this._track.current.clientId,
|
|
77
|
-
};
|
|
78
|
-
});
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
public get current(): Readonly<ITransportState> {
|
|
82
|
-
return this._current;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
public get playbackState(): ExtendedMediaSessionPlaybackState {
|
|
86
|
-
return this.current.playbackState;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
public get startPosition(): number {
|
|
90
|
-
return this.current.startPosition;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
public get timestamp(): number {
|
|
94
|
-
return this.current.timestamp;
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
public get track(): GroupPlaybackTrack {
|
|
98
|
-
return this._track;
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
public compare(state: ITransportState): boolean {
|
|
102
|
-
return (
|
|
103
|
-
this.current.playbackState == state.playbackState &&
|
|
104
|
-
this.current.startPosition == state.startPosition
|
|
105
|
-
);
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
public updateState(
|
|
109
|
-
state: ITransportState,
|
|
110
|
-
source: ExtendedMediaSessionActionSource
|
|
111
|
-
): boolean {
|
|
112
|
-
// Ignore if same playback state and start position
|
|
113
|
-
if (this.compare(state)) {
|
|
114
|
-
return false;
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
// Ignore state changes that are older
|
|
118
|
-
const originalState = this.current;
|
|
119
|
-
if (state.timestamp < originalState.timestamp) {
|
|
120
|
-
return false;
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
// Ignore state changes that have the same timestamp and the clientId sorts higher.
|
|
124
|
-
if (
|
|
125
|
-
state.timestamp == originalState.timestamp &&
|
|
126
|
-
state.clientId.localeCompare(originalState.clientId) > 0
|
|
127
|
-
) {
|
|
128
|
-
return false;
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
// Update playback state
|
|
132
|
-
this._current = state;
|
|
133
|
-
|
|
134
|
-
// Trigger transport change
|
|
135
|
-
const playerState = this._getMediaPlayerState().playbackState;
|
|
136
|
-
if (
|
|
137
|
-
originalState.playbackState == state.playbackState &&
|
|
138
|
-
playerState != "ended"
|
|
139
|
-
) {
|
|
140
|
-
this.emit(GroupTransportStateEvents.transportStateChange, {
|
|
141
|
-
type: GroupTransportStateEvents.transportStateChange,
|
|
142
|
-
action: "seekto",
|
|
143
|
-
clientId: state.clientId,
|
|
144
|
-
seekTime: state.startPosition,
|
|
145
|
-
source,
|
|
146
|
-
});
|
|
147
|
-
} else if (state.playbackState == "playing") {
|
|
148
|
-
const now = this._liveRuntime.getTimestamp();
|
|
149
|
-
const projectedPosition =
|
|
150
|
-
state.startPosition + (now - state.timestamp) / 1000;
|
|
151
|
-
this.emit(GroupTransportStateEvents.transportStateChange, {
|
|
152
|
-
type: GroupTransportStateEvents.transportStateChange,
|
|
153
|
-
action: "play",
|
|
154
|
-
clientId: state.clientId,
|
|
155
|
-
seekTime: projectedPosition,
|
|
156
|
-
source,
|
|
157
|
-
});
|
|
158
|
-
} else {
|
|
159
|
-
this.emit(GroupTransportStateEvents.transportStateChange, {
|
|
160
|
-
type: GroupTransportStateEvents.transportStateChange,
|
|
161
|
-
action: "pause",
|
|
162
|
-
clientId: state.clientId,
|
|
163
|
-
seekTime: state.startPosition,
|
|
164
|
-
source,
|
|
165
|
-
});
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
return true;
|
|
169
|
-
}
|
|
170
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
|
+
* Licensed under the Microsoft Live Share SDK License.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { ILiveEvent, LiveShareRuntime } from "@microsoft/live-share";
|
|
7
|
+
import EventEmitter from "events";
|
|
8
|
+
import { IMediaPlayerState } from "../LiveMediaSessionCoordinator";
|
|
9
|
+
import {
|
|
10
|
+
ExtendedMediaSessionPlaybackState,
|
|
11
|
+
ExtendedMediaSessionAction,
|
|
12
|
+
ExtendedMediaSessionActionSource,
|
|
13
|
+
} from "../MediaSessionExtensions";
|
|
14
|
+
import {
|
|
15
|
+
GroupPlaybackTrack,
|
|
16
|
+
GroupPlaybackTrackEvents,
|
|
17
|
+
} from "./GroupPlaybackTrack";
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* @hidden
|
|
21
|
+
*/
|
|
22
|
+
export interface ITransportState {
|
|
23
|
+
playbackState: ExtendedMediaSessionPlaybackState;
|
|
24
|
+
startPosition: number;
|
|
25
|
+
timestamp: number;
|
|
26
|
+
clientId: string;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* @hidden
|
|
31
|
+
*/
|
|
32
|
+
export enum GroupTransportStateEvents {
|
|
33
|
+
transportStateChange = "transportStateChange",
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* @hidden
|
|
38
|
+
*/
|
|
39
|
+
export interface ITransportStateChangeEvent extends ILiveEvent {
|
|
40
|
+
action: ExtendedMediaSessionAction;
|
|
41
|
+
seekTime?: number;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* @hidden
|
|
46
|
+
*/
|
|
47
|
+
export class GroupTransportState extends EventEmitter {
|
|
48
|
+
private readonly _getMediaPlayerState: () => IMediaPlayerState;
|
|
49
|
+
private _track: GroupPlaybackTrack;
|
|
50
|
+
private readonly _liveRuntime: LiveShareRuntime;
|
|
51
|
+
private _current: ITransportState;
|
|
52
|
+
|
|
53
|
+
constructor(
|
|
54
|
+
track: GroupPlaybackTrack,
|
|
55
|
+
getMediaPlayerState: () => IMediaPlayerState,
|
|
56
|
+
liveRuntime: LiveShareRuntime
|
|
57
|
+
) {
|
|
58
|
+
super();
|
|
59
|
+
this._liveRuntime = liveRuntime;
|
|
60
|
+
this._getMediaPlayerState = getMediaPlayerState;
|
|
61
|
+
this._track = track;
|
|
62
|
+
this._current = {
|
|
63
|
+
playbackState: "none",
|
|
64
|
+
startPosition: 0.0,
|
|
65
|
+
timestamp: 0,
|
|
66
|
+
clientId: "",
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
// Listen for track changes
|
|
70
|
+
this._track.on(GroupPlaybackTrackEvents.trackChange, () => {
|
|
71
|
+
// Track changed so reset state to stopped ad position 0.0
|
|
72
|
+
this._current = {
|
|
73
|
+
playbackState: "none",
|
|
74
|
+
startPosition: 0.0,
|
|
75
|
+
timestamp: this._track.current.timestamp,
|
|
76
|
+
clientId: this._track.current.clientId,
|
|
77
|
+
};
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
public get current(): Readonly<ITransportState> {
|
|
82
|
+
return this._current;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
public get playbackState(): ExtendedMediaSessionPlaybackState {
|
|
86
|
+
return this.current.playbackState;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
public get startPosition(): number {
|
|
90
|
+
return this.current.startPosition;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
public get timestamp(): number {
|
|
94
|
+
return this.current.timestamp;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
public get track(): GroupPlaybackTrack {
|
|
98
|
+
return this._track;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
public compare(state: ITransportState): boolean {
|
|
102
|
+
return (
|
|
103
|
+
this.current.playbackState == state.playbackState &&
|
|
104
|
+
this.current.startPosition == state.startPosition
|
|
105
|
+
);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
public updateState(
|
|
109
|
+
state: ITransportState,
|
|
110
|
+
source: ExtendedMediaSessionActionSource
|
|
111
|
+
): boolean {
|
|
112
|
+
// Ignore if same playback state and start position
|
|
113
|
+
if (this.compare(state)) {
|
|
114
|
+
return false;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
// Ignore state changes that are older
|
|
118
|
+
const originalState = this.current;
|
|
119
|
+
if (state.timestamp < originalState.timestamp) {
|
|
120
|
+
return false;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
// Ignore state changes that have the same timestamp and the clientId sorts higher.
|
|
124
|
+
if (
|
|
125
|
+
state.timestamp == originalState.timestamp &&
|
|
126
|
+
state.clientId.localeCompare(originalState.clientId) > 0
|
|
127
|
+
) {
|
|
128
|
+
return false;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
// Update playback state
|
|
132
|
+
this._current = state;
|
|
133
|
+
|
|
134
|
+
// Trigger transport change
|
|
135
|
+
const playerState = this._getMediaPlayerState().playbackState;
|
|
136
|
+
if (
|
|
137
|
+
originalState.playbackState == state.playbackState &&
|
|
138
|
+
playerState != "ended"
|
|
139
|
+
) {
|
|
140
|
+
this.emit(GroupTransportStateEvents.transportStateChange, {
|
|
141
|
+
type: GroupTransportStateEvents.transportStateChange,
|
|
142
|
+
action: "seekto",
|
|
143
|
+
clientId: state.clientId,
|
|
144
|
+
seekTime: state.startPosition,
|
|
145
|
+
source,
|
|
146
|
+
});
|
|
147
|
+
} else if (state.playbackState == "playing") {
|
|
148
|
+
const now = this._liveRuntime.getTimestamp();
|
|
149
|
+
const projectedPosition =
|
|
150
|
+
state.startPosition + (now - state.timestamp) / 1000;
|
|
151
|
+
this.emit(GroupTransportStateEvents.transportStateChange, {
|
|
152
|
+
type: GroupTransportStateEvents.transportStateChange,
|
|
153
|
+
action: "play",
|
|
154
|
+
clientId: state.clientId,
|
|
155
|
+
seekTime: projectedPosition,
|
|
156
|
+
source,
|
|
157
|
+
});
|
|
158
|
+
} else {
|
|
159
|
+
this.emit(GroupTransportStateEvents.transportStateChange, {
|
|
160
|
+
type: GroupTransportStateEvents.transportStateChange,
|
|
161
|
+
action: "pause",
|
|
162
|
+
clientId: state.clientId,
|
|
163
|
+
seekTime: state.startPosition,
|
|
164
|
+
source,
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
return true;
|
|
169
|
+
}
|
|
170
|
+
}
|
package/src/internals/consts.ts
CHANGED
|
@@ -1,102 +1,103 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
|
-
* Licensed under the Microsoft Live Share SDK License.
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* @hidden
|
|
8
|
-
* List of telemetry events. Wrap with a call to transmit() if the event should be transmitted to
|
|
9
|
-
* the telemetry service.
|
|
10
|
-
*/
|
|
11
|
-
export const TelemetryEvents = {
|
|
12
|
-
MediaPlayerSynchronizer: {
|
|
13
|
-
SynchronizationStarted:
|
|
14
|
-
"MediaPlayerSynchronizer:SynchronizationStarted",
|
|
15
|
-
PlayerEvent: "MediaPlayerSynchronizer:PlayerEvent",
|
|
16
|
-
PlayAction: "MediaPlayerSynchronizer:PlayAction",
|
|
17
|
-
PauseAction: "MediaPlayerSynchronizer:PauseAction",
|
|
18
|
-
SeekToAction: "MediaPlayerSynchronizer:SeekToAction",
|
|
19
|
-
CatchupAction: "MediaPlayerSynchronizer:CatchupAction",
|
|
20
|
-
SetTrackAction: "MediaPlayerSynchronizer:SetTrackAction",
|
|
21
|
-
DataChangeAction: "MediaPlayerSynchronizer:DataChangeAction",
|
|
22
|
-
UserTappedVideoToPlay: transmit(
|
|
23
|
-
"MediaPlayerSynchronizer:UserTappedVideoToPlay"
|
|
24
|
-
),
|
|
25
|
-
UserTappedVideoToPlayError:
|
|
26
|
-
"MediaPlayerSynchronizer:UserTappedVideoToPlayError",
|
|
27
|
-
PlaybackRateChangeBlocked:
|
|
28
|
-
"MediaPlayerSynchronizer:PlaybackRateChangeBlocked",
|
|
29
|
-
PlayerBlockedOperation: transmit(
|
|
30
|
-
"MediaPlayerSynchronizer:PlayerBlockedOperation"
|
|
31
|
-
),
|
|
32
|
-
SeekingPlayerToStartPosition:
|
|
33
|
-
"MediaPlayerSynchronizer:SeekingPlayerToStartPosition",
|
|
34
|
-
BeginSeekCalled: "MediaPlayerSynchronizer:BeginSeekCalled",
|
|
35
|
-
EndSeekCalled: "MediaPlayerSynchronizer:EndSeekCalled",
|
|
36
|
-
PlayCalled: "MediaPlayerSynchronizer:PlayCalled",
|
|
37
|
-
PauseCalled: "MediaPlayerSynchronizer:PauseCalled",
|
|
38
|
-
SeekToCalled: "MediaPlayerSynchronizer:SeekToCalled",
|
|
39
|
-
SetTrackCalled: "MediaPlayerSynchronizer:SetTrackCalled",
|
|
40
|
-
SetTrackDataCalled: "MediaPlayerSynchronizer:SetTrackDataCalled",
|
|
41
|
-
},
|
|
42
|
-
MediaSession: {
|
|
43
|
-
PlayAction: transmit("MediaSession:PlayAction"),
|
|
44
|
-
PauseAction: transmit("MediaSession:PauseAction"),
|
|
45
|
-
SeekToAction: transmit("MediaSession:SeekToAction"),
|
|
46
|
-
CatchUpAction: transmit("MediaSession:CatchUpAction"),
|
|
47
|
-
SetTrackAction: transmit("MediaSession:SetTrackAction"),
|
|
48
|
-
DataChangeAction: "MediaSession:DataChangeAction",
|
|
49
|
-
BeginPositionUpdateTimer: "MediaSession:BeginPositionUpdateTimer",
|
|
50
|
-
},
|
|
51
|
-
SessionCoordinator: {
|
|
52
|
-
PlayCalled: transmit("SessionCoordinator:PlayCalled"),
|
|
53
|
-
PauseCalled: transmit("SessionCoordinator:PauseCalled"),
|
|
54
|
-
SeekToCalled: transmit("SessionCoordinator:SeekToCalled"),
|
|
55
|
-
SetTrackCalled: transmit("SessionCoordinator:SetTrackCalled"),
|
|
56
|
-
SetTrackDataCalled: "SessionCoordinator:SetTrackDataCalled",
|
|
57
|
-
BeginSuspension: "SessionCoordinator:BeginSuspension",
|
|
58
|
-
BeginSuspensionAndWait: transmit(
|
|
59
|
-
"SessionCoordinator:BeginSuspensionAndWait"
|
|
60
|
-
),
|
|
61
|
-
EndSuspension: "SessionCoordinator:EndSuspension",
|
|
62
|
-
EndSuspensionAndWait: transmit(
|
|
63
|
-
"SessionCoordinator:EndSuspensionAndWait"
|
|
64
|
-
),
|
|
65
|
-
|
|
66
|
-
RemoteSetTrackReceived: transmit(
|
|
67
|
-
"SessionCoordinator:RemoteSetTrackReceived"
|
|
68
|
-
),
|
|
69
|
-
RemoteSetTrackDataReceived: transmit(
|
|
70
|
-
"SessionCoordinator:RemoteSetTrackDataReceived"
|
|
71
|
-
),
|
|
72
|
-
RemotePlayReceived: transmit("SessionCoordinator:RemotePlayReceived"),
|
|
73
|
-
RemotePauseReceived: transmit("SessionCoordinator:RemotePauseReceived"),
|
|
74
|
-
RemoteSeekToReceived: transmit(
|
|
75
|
-
"SessionCoordinator:RemoteSeekToReceived"
|
|
76
|
-
),
|
|
77
|
-
PositionUpdateEventError: "SessionCoordinator:PositionUpdateEventError",
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
|
+
* Licensed under the Microsoft Live Share SDK License.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* @hidden
|
|
8
|
+
* List of telemetry events. Wrap with a call to transmit() if the event should be transmitted to
|
|
9
|
+
* the telemetry service.
|
|
10
|
+
*/
|
|
11
|
+
export const TelemetryEvents = {
|
|
12
|
+
MediaPlayerSynchronizer: {
|
|
13
|
+
SynchronizationStarted:
|
|
14
|
+
"MediaPlayerSynchronizer:SynchronizationStarted",
|
|
15
|
+
PlayerEvent: "MediaPlayerSynchronizer:PlayerEvent",
|
|
16
|
+
PlayAction: "MediaPlayerSynchronizer:PlayAction",
|
|
17
|
+
PauseAction: "MediaPlayerSynchronizer:PauseAction",
|
|
18
|
+
SeekToAction: "MediaPlayerSynchronizer:SeekToAction",
|
|
19
|
+
CatchupAction: "MediaPlayerSynchronizer:CatchupAction",
|
|
20
|
+
SetTrackAction: "MediaPlayerSynchronizer:SetTrackAction",
|
|
21
|
+
DataChangeAction: "MediaPlayerSynchronizer:DataChangeAction",
|
|
22
|
+
UserTappedVideoToPlay: transmit(
|
|
23
|
+
"MediaPlayerSynchronizer:UserTappedVideoToPlay"
|
|
24
|
+
),
|
|
25
|
+
UserTappedVideoToPlayError:
|
|
26
|
+
"MediaPlayerSynchronizer:UserTappedVideoToPlayError",
|
|
27
|
+
PlaybackRateChangeBlocked:
|
|
28
|
+
"MediaPlayerSynchronizer:PlaybackRateChangeBlocked",
|
|
29
|
+
PlayerBlockedOperation: transmit(
|
|
30
|
+
"MediaPlayerSynchronizer:PlayerBlockedOperation"
|
|
31
|
+
),
|
|
32
|
+
SeekingPlayerToStartPosition:
|
|
33
|
+
"MediaPlayerSynchronizer:SeekingPlayerToStartPosition",
|
|
34
|
+
BeginSeekCalled: "MediaPlayerSynchronizer:BeginSeekCalled",
|
|
35
|
+
EndSeekCalled: "MediaPlayerSynchronizer:EndSeekCalled",
|
|
36
|
+
PlayCalled: "MediaPlayerSynchronizer:PlayCalled",
|
|
37
|
+
PauseCalled: "MediaPlayerSynchronizer:PauseCalled",
|
|
38
|
+
SeekToCalled: "MediaPlayerSynchronizer:SeekToCalled",
|
|
39
|
+
SetTrackCalled: "MediaPlayerSynchronizer:SetTrackCalled",
|
|
40
|
+
SetTrackDataCalled: "MediaPlayerSynchronizer:SetTrackDataCalled",
|
|
41
|
+
},
|
|
42
|
+
MediaSession: {
|
|
43
|
+
PlayAction: transmit("MediaSession:PlayAction"),
|
|
44
|
+
PauseAction: transmit("MediaSession:PauseAction"),
|
|
45
|
+
SeekToAction: transmit("MediaSession:SeekToAction"),
|
|
46
|
+
CatchUpAction: transmit("MediaSession:CatchUpAction"),
|
|
47
|
+
SetTrackAction: transmit("MediaSession:SetTrackAction"),
|
|
48
|
+
DataChangeAction: "MediaSession:DataChangeAction",
|
|
49
|
+
BeginPositionUpdateTimer: "MediaSession:BeginPositionUpdateTimer",
|
|
50
|
+
},
|
|
51
|
+
SessionCoordinator: {
|
|
52
|
+
PlayCalled: transmit("SessionCoordinator:PlayCalled"),
|
|
53
|
+
PauseCalled: transmit("SessionCoordinator:PauseCalled"),
|
|
54
|
+
SeekToCalled: transmit("SessionCoordinator:SeekToCalled"),
|
|
55
|
+
SetTrackCalled: transmit("SessionCoordinator:SetTrackCalled"),
|
|
56
|
+
SetTrackDataCalled: "SessionCoordinator:SetTrackDataCalled",
|
|
57
|
+
BeginSuspension: "SessionCoordinator:BeginSuspension",
|
|
58
|
+
BeginSuspensionAndWait: transmit(
|
|
59
|
+
"SessionCoordinator:BeginSuspensionAndWait"
|
|
60
|
+
),
|
|
61
|
+
EndSuspension: "SessionCoordinator:EndSuspension",
|
|
62
|
+
EndSuspensionAndWait: transmit(
|
|
63
|
+
"SessionCoordinator:EndSuspensionAndWait"
|
|
64
|
+
),
|
|
65
|
+
RemoteConnectReceived: "SessionCoordinator:RemoteConnectReceived",
|
|
66
|
+
RemoteSetTrackReceived: transmit(
|
|
67
|
+
"SessionCoordinator:RemoteSetTrackReceived"
|
|
68
|
+
),
|
|
69
|
+
RemoteSetTrackDataReceived: transmit(
|
|
70
|
+
"SessionCoordinator:RemoteSetTrackDataReceived"
|
|
71
|
+
),
|
|
72
|
+
RemotePlayReceived: transmit("SessionCoordinator:RemotePlayReceived"),
|
|
73
|
+
RemotePauseReceived: transmit("SessionCoordinator:RemotePauseReceived"),
|
|
74
|
+
RemoteSeekToReceived: transmit(
|
|
75
|
+
"SessionCoordinator:RemoteSeekToReceived"
|
|
76
|
+
),
|
|
77
|
+
PositionUpdateEventError: "SessionCoordinator:PositionUpdateEventError",
|
|
78
|
+
LiveObjectSynchronizerStartError:
|
|
79
|
+
"SessionCoordinator:LiveObjectSynchronizerStartError",
|
|
80
|
+
},
|
|
81
|
+
GroupCoordinator: {
|
|
82
|
+
TrackChanged: "GroupCoordinator:TrackChanged",
|
|
83
|
+
TrackChangeDelayed: "GroupCoordinator:TrackChangeDelayed",
|
|
84
|
+
TrackDataChanged: "GroupCoordinator:TrackDataChanged",
|
|
85
|
+
TrackDataChangeDelayed: "GroupCoordinator:TrackDataChangeDelayed",
|
|
86
|
+
TransportStateChanged: "GroupCoordinator:TransportStateChanged",
|
|
87
|
+
TransportStateChangeDelayed:
|
|
88
|
+
"GroupCoordinator:TransportStateChangeDelayed",
|
|
89
|
+
BeginSoftSuspension: "GroupCoordinator:BeginSoftSuspension",
|
|
90
|
+
CheckingForSyncIssues: "GroupCoordinator:CheckingForSyncIssues",
|
|
91
|
+
TrackOutOfSync: transmit("GroupCoordinator:TrackOutOfSync"),
|
|
92
|
+
TrackDataOutOfSync: transmit("GroupCoordinator:TrackDataOutOfSync"),
|
|
93
|
+
TransportOutOfSync: transmit("GroupCoordinator:TransportOutOfSync"),
|
|
94
|
+
PositionOutOfSync: transmit("GroupCoordinator:PositionOutOfSync"),
|
|
95
|
+
},
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* @hidden
|
|
100
|
+
*/
|
|
101
|
+
function transmit(eventName: string): string {
|
|
102
|
+
return `${eventName}#transmit`;
|
|
103
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @hidden
|
|
3
|
+
* Use for operations that are blocked due to the metadata not being set.
|
|
4
|
+
*/
|
|
5
|
+
export class TrackMetadataNotSetError extends Error {
|
|
6
|
+
constructor(prefix: string, callingFunction: string) {
|
|
7
|
+
super(
|
|
8
|
+
`${prefix} - called before playback track metadata has been assigned.\nTo fix this error, ensure \`setTrack()\` has been called with the track information before calling \`${callingFunction}()\``
|
|
9
|
+
);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
static assert(
|
|
13
|
+
condition: boolean,
|
|
14
|
+
prefix: string,
|
|
15
|
+
callingFunction: string
|
|
16
|
+
): asserts condition {
|
|
17
|
+
if (condition) return;
|
|
18
|
+
throw new TrackMetadataNotSetError(prefix, callingFunction);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* @hidden
|
|
24
|
+
* Use for operations that are blocked due to the metadata not being set.
|
|
25
|
+
*/
|
|
26
|
+
export class ActionBlockedError extends Error {
|
|
27
|
+
constructor(prefix: string, callingFunction: string, settingName: string) {
|
|
28
|
+
super(
|
|
29
|
+
`${prefix} - operation blocked due to \`${settingName}\` being set to false.\nTo fix this error, ensure \`${settingName}\` is true before calling \`${callingFunction}()\`, or set \`${settingName}\` to true. If you are using \`MediaPlayerSynchronizer\`, you can instead use the \`viewOnly\`, which when set to false, it will set \`${settingName}\` value to true.`
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
static assert(
|
|
34
|
+
condition: boolean,
|
|
35
|
+
prefix: string,
|
|
36
|
+
callingFunction: string,
|
|
37
|
+
settingName: string
|
|
38
|
+
): asserts condition {
|
|
39
|
+
if (condition) return;
|
|
40
|
+
throw new ActionBlockedError(prefix, callingFunction, settingName);
|
|
41
|
+
}
|
|
42
|
+
}
|
package/src/internals/index.ts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
|
-
* Licensed under the Microsoft Live Share SDK License.
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
export * from "./consts";
|
|
7
|
-
export * from "./GroupCoordinatorState";
|
|
8
|
-
export * from "./GroupPlaybackPosition";
|
|
9
|
-
export * from "./GroupPlaybackTrack";
|
|
10
|
-
export * from "./GroupPlaybackTrackData";
|
|
11
|
-
export * from "./GroupTransportState";
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
|
+
* Licensed under the Microsoft Live Share SDK License.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
export * from "./consts";
|
|
7
|
+
export * from "./GroupCoordinatorState";
|
|
8
|
+
export * from "./GroupPlaybackPosition";
|
|
9
|
+
export * from "./GroupPlaybackTrack";
|
|
10
|
+
export * from "./GroupPlaybackTrackData";
|
|
11
|
+
export * from "./GroupTransportState";
|
|
12
|
+
export * from "./errors";
|
package/tsconfig.build.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
{
|
|
2
|
-
"extends": "./tsconfig.json",
|
|
3
|
-
"compilerOptions": {
|
|
4
|
-
"target": "es6" /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */
|
|
5
|
-
},
|
|
6
|
-
"exclude": [
|
|
7
|
-
"test/**/*.ts"
|
|
8
|
-
]
|
|
1
|
+
{
|
|
2
|
+
"extends": "./tsconfig.json",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"target": "es6" /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */
|
|
5
|
+
},
|
|
6
|
+
"exclude": [
|
|
7
|
+
"test/**/*.ts"
|
|
8
|
+
]
|
|
9
9
|
}
|