@microsoft/live-share-media 1.3.1 → 2.0.0-internal.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/bin/LiveMediaSession.d.ts.map +1 -1
- package/bin/LiveMediaSession.js +9 -1
- package/bin/LiveMediaSession.js.map +1 -1
- package/bin/LiveMediaSessionCoordinator.d.ts +15 -0
- package/bin/LiveMediaSessionCoordinator.d.ts.map +1 -1
- package/bin/LiveMediaSessionCoordinator.js +25 -0
- package/bin/LiveMediaSessionCoordinator.js.map +1 -1
- package/bin/MediaPlayerSynchronizer.d.ts +6 -4
- package/bin/MediaPlayerSynchronizer.d.ts.map +1 -1
- package/bin/MediaPlayerSynchronizer.js +43 -14
- package/bin/MediaPlayerSynchronizer.js.map +1 -1
- package/bin/MediaSessionExtensions.d.ts +17 -4
- package/bin/MediaSessionExtensions.d.ts.map +1 -1
- package/bin/MediaSessionExtensions.js +5 -1
- package/bin/MediaSessionExtensions.js.map +1 -1
- package/bin/RepeatedActionThrottler.js +1 -1
- package/bin/RepeatedActionThrottler.js.map +1 -1
- package/bin/VolumeManager.js +1 -1
- package/bin/VolumeManager.js.map +1 -1
- package/bin/internals/GroupCoordinatorState.d.ts +15 -1
- package/bin/internals/GroupCoordinatorState.d.ts.map +1 -1
- package/bin/internals/GroupCoordinatorState.js +124 -58
- package/bin/internals/GroupCoordinatorState.js.map +1 -1
- package/bin/internals/GroupPlaybackPosition.d.ts +3 -1
- package/bin/internals/GroupPlaybackPosition.d.ts.map +1 -1
- package/bin/internals/GroupPlaybackPosition.js +7 -3
- package/bin/internals/GroupPlaybackPosition.js.map +1 -1
- package/bin/internals/GroupPlaybackRate.d.ts +39 -0
- package/bin/internals/GroupPlaybackRate.d.ts.map +1 -0
- package/bin/internals/GroupPlaybackRate.js +62 -0
- package/bin/internals/GroupPlaybackRate.js.map +1 -0
- package/bin/internals/GroupPlaybackTrack.d.ts +2 -2
- package/bin/internals/GroupPlaybackTrack.d.ts.map +1 -1
- package/bin/internals/GroupPlaybackTrack.js +4 -3
- package/bin/internals/GroupPlaybackTrack.js.map +1 -1
- package/bin/internals/GroupPlaybackTrackData.d.ts +3 -3
- package/bin/internals/GroupPlaybackTrackData.d.ts.map +1 -1
- package/bin/internals/GroupPlaybackTrackData.js +13 -12
- package/bin/internals/GroupPlaybackTrackData.js.map +1 -1
- package/bin/internals/GroupTransportState.d.ts +6 -3
- package/bin/internals/GroupTransportState.d.ts.map +1 -1
- package/bin/internals/GroupTransportState.js +17 -12
- package/bin/internals/GroupTransportState.js.map +1 -1
- package/bin/internals/consts.d.ts +8 -1
- package/bin/internals/consts.d.ts.map +1 -1
- package/bin/internals/consts.js +8 -1
- package/bin/internals/consts.js.map +1 -1
- 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/bin/internals/interfaces.d.ts +10 -0
- package/bin/internals/interfaces.d.ts.map +1 -0
- package/bin/internals/interfaces.js +3 -0
- package/bin/internals/interfaces.js.map +1 -0
- package/package.json +6 -9
- package/src/LiveMediaSession.ts +12 -0
- package/src/LiveMediaSessionCoordinator.ts +49 -0
- package/src/MediaPlayerSynchronizer.ts +55 -15
- package/src/MediaSessionExtensions.ts +18 -2
- package/src/internals/GroupCoordinatorState.ts +196 -79
- package/src/internals/GroupPlaybackPosition.ts +9 -2
- package/src/internals/GroupPlaybackRate.ts +90 -0
- package/src/internals/GroupPlaybackTrack.ts +5 -4
- package/src/internals/GroupPlaybackTrackData.ts +14 -13
- package/src/internals/GroupTransportState.ts +21 -12
- package/src/internals/consts.ts +14 -2
- package/src/internals/index.ts +1 -0
- package/src/internals/interfaces.ts +10 -0
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Licensed under the Microsoft Live Share SDK License.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import {
|
|
6
|
+
import { LiveShareRuntime } from "@microsoft/live-share";
|
|
7
7
|
import EventEmitter from "events";
|
|
8
8
|
import { IMediaPlayerState } from "../LiveMediaSessionCoordinator";
|
|
9
9
|
import {
|
|
@@ -15,6 +15,8 @@ import {
|
|
|
15
15
|
GroupPlaybackTrack,
|
|
16
16
|
GroupPlaybackTrackEvents,
|
|
17
17
|
} from "./GroupPlaybackTrack";
|
|
18
|
+
import { IGroupStateEvent } from "./interfaces";
|
|
19
|
+
import { GroupPlaybackRate } from "./GroupPlaybackRate";
|
|
18
20
|
|
|
19
21
|
/**
|
|
20
22
|
* @hidden
|
|
@@ -36,7 +38,7 @@ export enum GroupTransportStateEvents {
|
|
|
36
38
|
/**
|
|
37
39
|
* @hidden
|
|
38
40
|
*/
|
|
39
|
-
export interface ITransportStateChangeEvent extends
|
|
41
|
+
export interface ITransportStateChangeEvent extends IGroupStateEvent {
|
|
40
42
|
action: ExtendedMediaSessionAction;
|
|
41
43
|
seekTime?: number;
|
|
42
44
|
}
|
|
@@ -47,11 +49,13 @@ export interface ITransportStateChangeEvent extends ILiveEvent {
|
|
|
47
49
|
export class GroupTransportState extends EventEmitter {
|
|
48
50
|
private readonly _getMediaPlayerState: () => IMediaPlayerState;
|
|
49
51
|
private _track: GroupPlaybackTrack;
|
|
52
|
+
private _playbackRate: GroupPlaybackRate;
|
|
50
53
|
private readonly _liveRuntime: LiveShareRuntime;
|
|
51
54
|
private _current: ITransportState;
|
|
52
55
|
|
|
53
56
|
constructor(
|
|
54
57
|
track: GroupPlaybackTrack,
|
|
58
|
+
playbackRate: GroupPlaybackRate,
|
|
55
59
|
getMediaPlayerState: () => IMediaPlayerState,
|
|
56
60
|
liveRuntime: LiveShareRuntime
|
|
57
61
|
) {
|
|
@@ -59,6 +63,7 @@ export class GroupTransportState extends EventEmitter {
|
|
|
59
63
|
this._liveRuntime = liveRuntime;
|
|
60
64
|
this._getMediaPlayerState = getMediaPlayerState;
|
|
61
65
|
this._track = track;
|
|
66
|
+
this._playbackRate = playbackRate;
|
|
62
67
|
this._current = {
|
|
63
68
|
playbackState: "none",
|
|
64
69
|
startPosition: 0.0,
|
|
@@ -137,32 +142,36 @@ export class GroupTransportState extends EventEmitter {
|
|
|
137
142
|
originalState.playbackState == state.playbackState &&
|
|
138
143
|
playerState != "ended"
|
|
139
144
|
) {
|
|
140
|
-
|
|
141
|
-
|
|
145
|
+
const event: ITransportStateChangeEvent = {
|
|
146
|
+
name: GroupTransportStateEvents.transportStateChange,
|
|
142
147
|
action: "seekto",
|
|
143
148
|
clientId: state.clientId,
|
|
144
149
|
seekTime: state.startPosition,
|
|
145
150
|
source,
|
|
146
|
-
}
|
|
151
|
+
};
|
|
152
|
+
this.emit(GroupTransportStateEvents.transportStateChange, event);
|
|
147
153
|
} else if (state.playbackState == "playing") {
|
|
148
154
|
const now = this._liveRuntime.getTimestamp();
|
|
149
155
|
const projectedPosition =
|
|
150
|
-
state.startPosition +
|
|
151
|
-
|
|
152
|
-
|
|
156
|
+
state.startPosition +
|
|
157
|
+
((now - state.timestamp) / 1000) * this._playbackRate.rate;
|
|
158
|
+
const event: ITransportStateChangeEvent = {
|
|
159
|
+
name: GroupTransportStateEvents.transportStateChange,
|
|
153
160
|
action: "play",
|
|
154
161
|
clientId: state.clientId,
|
|
155
162
|
seekTime: projectedPosition,
|
|
156
163
|
source,
|
|
157
|
-
}
|
|
164
|
+
};
|
|
165
|
+
this.emit(GroupTransportStateEvents.transportStateChange, event);
|
|
158
166
|
} else {
|
|
159
|
-
|
|
160
|
-
|
|
167
|
+
const event: ITransportStateChangeEvent = {
|
|
168
|
+
name: GroupTransportStateEvents.transportStateChange,
|
|
161
169
|
action: "pause",
|
|
162
170
|
clientId: state.clientId,
|
|
163
171
|
seekTime: state.startPosition,
|
|
164
172
|
source,
|
|
165
|
-
}
|
|
173
|
+
};
|
|
174
|
+
this.emit(GroupTransportStateEvents.transportStateChange, event);
|
|
166
175
|
}
|
|
167
176
|
|
|
168
177
|
return true;
|
package/src/internals/consts.ts
CHANGED
|
@@ -16,6 +16,7 @@ export const TelemetryEvents = {
|
|
|
16
16
|
PlayAction: "MediaPlayerSynchronizer:PlayAction",
|
|
17
17
|
PauseAction: "MediaPlayerSynchronizer:PauseAction",
|
|
18
18
|
SeekToAction: "MediaPlayerSynchronizer:SeekToAction",
|
|
19
|
+
RateChangeAction: "MediaPlayerSynchronizer:RateChangeAction",
|
|
19
20
|
CatchupAction: "MediaPlayerSynchronizer:CatchupAction",
|
|
20
21
|
SetTrackAction: "MediaPlayerSynchronizer:SetTrackAction",
|
|
21
22
|
DataChangeAction: "MediaPlayerSynchronizer:DataChangeAction",
|
|
@@ -24,8 +25,6 @@ export const TelemetryEvents = {
|
|
|
24
25
|
),
|
|
25
26
|
UserTappedVideoToPlayError:
|
|
26
27
|
"MediaPlayerSynchronizer:UserTappedVideoToPlayError",
|
|
27
|
-
PlaybackRateChangeBlocked:
|
|
28
|
-
"MediaPlayerSynchronizer:PlaybackRateChangeBlocked",
|
|
29
28
|
PlayerBlockedOperation: transmit(
|
|
30
29
|
"MediaPlayerSynchronizer:PlayerBlockedOperation"
|
|
31
30
|
),
|
|
@@ -36,6 +35,7 @@ export const TelemetryEvents = {
|
|
|
36
35
|
PlayCalled: "MediaPlayerSynchronizer:PlayCalled",
|
|
37
36
|
PauseCalled: "MediaPlayerSynchronizer:PauseCalled",
|
|
38
37
|
SeekToCalled: "MediaPlayerSynchronizer:SeekToCalled",
|
|
38
|
+
RateChangeCalled: "MediaSession:RateChangeCalled",
|
|
39
39
|
SetTrackCalled: "MediaPlayerSynchronizer:SetTrackCalled",
|
|
40
40
|
SetTrackDataCalled: "MediaPlayerSynchronizer:SetTrackDataCalled",
|
|
41
41
|
},
|
|
@@ -43,6 +43,7 @@ export const TelemetryEvents = {
|
|
|
43
43
|
PlayAction: transmit("MediaSession:PlayAction"),
|
|
44
44
|
PauseAction: transmit("MediaSession:PauseAction"),
|
|
45
45
|
SeekToAction: transmit("MediaSession:SeekToAction"),
|
|
46
|
+
RateChangeAction: transmit("MediaSession:RateChangeAction"),
|
|
46
47
|
CatchUpAction: transmit("MediaSession:CatchUpAction"),
|
|
47
48
|
SetTrackAction: transmit("MediaSession:SetTrackAction"),
|
|
48
49
|
DataChangeAction: "MediaSession:DataChangeAction",
|
|
@@ -52,6 +53,9 @@ export const TelemetryEvents = {
|
|
|
52
53
|
PlayCalled: transmit("SessionCoordinator:PlayCalled"),
|
|
53
54
|
PauseCalled: transmit("SessionCoordinator:PauseCalled"),
|
|
54
55
|
SeekToCalled: transmit("SessionCoordinator:SeekToCalled"),
|
|
56
|
+
SetPlaybackRateCalled: transmit(
|
|
57
|
+
"SessionCoordinator:SetPlaybackRateCalled"
|
|
58
|
+
),
|
|
55
59
|
SetTrackCalled: transmit("SessionCoordinator:SetTrackCalled"),
|
|
56
60
|
SetTrackDataCalled: "SessionCoordinator:SetTrackDataCalled",
|
|
57
61
|
BeginSuspension: "SessionCoordinator:BeginSuspension",
|
|
@@ -74,6 +78,9 @@ export const TelemetryEvents = {
|
|
|
74
78
|
RemoteSeekToReceived: transmit(
|
|
75
79
|
"SessionCoordinator:RemoteSeekToReceived"
|
|
76
80
|
),
|
|
81
|
+
RemoteRateChangeReceived: transmit(
|
|
82
|
+
"SessionCoordinator:RemoteRateChangeReceived"
|
|
83
|
+
),
|
|
77
84
|
PositionUpdateEventError: "SessionCoordinator:PositionUpdateEventError",
|
|
78
85
|
LiveObjectSynchronizerStartError:
|
|
79
86
|
"SessionCoordinator:LiveObjectSynchronizerStartError",
|
|
@@ -86,12 +93,17 @@ export const TelemetryEvents = {
|
|
|
86
93
|
TransportStateChanged: "GroupCoordinator:TransportStateChanged",
|
|
87
94
|
TransportStateChangeDelayed:
|
|
88
95
|
"GroupCoordinator:TransportStateChangeDelayed",
|
|
96
|
+
PlaybackRateChanged: "GroupCoordinator:PlaybackRateChanged",
|
|
97
|
+
PlaybackRateChangedDelayed: "GroupCoordinator:PlaybackRateChanged",
|
|
89
98
|
BeginSoftSuspension: "GroupCoordinator:BeginSoftSuspension",
|
|
90
99
|
CheckingForSyncIssues: "GroupCoordinator:CheckingForSyncIssues",
|
|
91
100
|
TrackOutOfSync: transmit("GroupCoordinator:TrackOutOfSync"),
|
|
92
101
|
TrackDataOutOfSync: transmit("GroupCoordinator:TrackDataOutOfSync"),
|
|
93
102
|
TransportOutOfSync: transmit("GroupCoordinator:TransportOutOfSync"),
|
|
94
103
|
PositionOutOfSync: transmit("GroupCoordinator:PositionOutOfSync"),
|
|
104
|
+
PlaybackRateOutOfSync: transmit(
|
|
105
|
+
"GroupCoordinator:PlaybackRateOutOfSync"
|
|
106
|
+
),
|
|
95
107
|
},
|
|
96
108
|
};
|
|
97
109
|
|
package/src/internals/index.ts
CHANGED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { IEvent } from "@microsoft/live-share";
|
|
2
|
+
import { ExtendedMediaSessionActionSource } from "../MediaSessionExtensions";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* @hidden
|
|
6
|
+
*/
|
|
7
|
+
export interface IGroupStateEvent extends IEvent {
|
|
8
|
+
clientId: string;
|
|
9
|
+
source: ExtendedMediaSessionActionSource;
|
|
10
|
+
}
|