@microsoft/live-share-media 1.0.0-preview.10 → 1.0.0-preview.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (89) hide show
  1. package/README.md +3 -4
  2. package/package.json +7 -5
  3. package/src/internals/GroupCoordinatorState.ts +3 -2
  4. package/src/internals/GroupPlaybackPosition.ts +3 -3
  5. package/src/internals/GroupTransportState.ts +2 -2
  6. package/bin/EphemeralMediaSession.d.ts +0 -102
  7. package/bin/EphemeralMediaSession.d.ts.map +0 -1
  8. package/bin/EphemeralMediaSession.js +0 -226
  9. package/bin/EphemeralMediaSession.js.map +0 -1
  10. package/bin/EphemeralMediaSessionCoordinator.d.ts +0 -228
  11. package/bin/EphemeralMediaSessionCoordinator.d.ts.map +0 -1
  12. package/bin/EphemeralMediaSessionCoordinator.js +0 -396
  13. package/bin/EphemeralMediaSessionCoordinator.js.map +0 -1
  14. package/bin/EphemeralMediaSessionCoordinatorSuspension.d.ts +0 -20
  15. package/bin/EphemeralMediaSessionCoordinatorSuspension.d.ts.map +0 -1
  16. package/bin/EphemeralMediaSessionCoordinatorSuspension.js +0 -28
  17. package/bin/EphemeralMediaSessionCoordinatorSuspension.js.map +0 -1
  18. package/bin/IMediaPlayer.d.ts +0 -21
  19. package/bin/IMediaPlayer.d.ts.map +0 -1
  20. package/bin/IMediaPlayer.js +0 -7
  21. package/bin/IMediaPlayer.js.map +0 -1
  22. package/bin/LiveMediaSession.d.ts +0 -95
  23. package/bin/LiveMediaSession.d.ts.map +0 -1
  24. package/bin/LiveMediaSession.js +0 -232
  25. package/bin/LiveMediaSession.js.map +0 -1
  26. package/bin/LiveMediaSessionCoordinator.d.ts +0 -228
  27. package/bin/LiveMediaSessionCoordinator.d.ts.map +0 -1
  28. package/bin/LiveMediaSessionCoordinator.js +0 -408
  29. package/bin/LiveMediaSessionCoordinator.js.map +0 -1
  30. package/bin/LiveMediaSessionCoordinatorSuspension.d.ts +0 -20
  31. package/bin/LiveMediaSessionCoordinatorSuspension.d.ts.map +0 -1
  32. package/bin/LiveMediaSessionCoordinatorSuspension.js +0 -28
  33. package/bin/LiveMediaSessionCoordinatorSuspension.js.map +0 -1
  34. package/bin/MediaPlayerSynchronizer.d.ts +0 -164
  35. package/bin/MediaPlayerSynchronizer.d.ts.map +0 -1
  36. package/bin/MediaPlayerSynchronizer.js +0 -469
  37. package/bin/MediaPlayerSynchronizer.js.map +0 -1
  38. package/bin/MediaSessionActionThrottler.d.ts +0 -12
  39. package/bin/MediaSessionActionThrottler.d.ts.map +0 -1
  40. package/bin/MediaSessionActionThrottler.js +0 -14
  41. package/bin/MediaSessionActionThrottler.js.map +0 -1
  42. package/bin/MediaSessionExtensions.d.ts +0 -35
  43. package/bin/MediaSessionExtensions.d.ts.map +0 -1
  44. package/bin/MediaSessionExtensions.js +0 -13
  45. package/bin/MediaSessionExtensions.js.map +0 -1
  46. package/bin/RepeatedActionThrottler.d.ts +0 -20
  47. package/bin/RepeatedActionThrottler.d.ts.map +0 -1
  48. package/bin/RepeatedActionThrottler.js +0 -63
  49. package/bin/RepeatedActionThrottler.js.map +0 -1
  50. package/bin/VolumeLimiter.d.ts +0 -70
  51. package/bin/VolumeLimiter.d.ts.map +0 -1
  52. package/bin/VolumeLimiter.js +0 -170
  53. package/bin/VolumeLimiter.js.map +0 -1
  54. package/bin/VolumeManager.d.ts +0 -84
  55. package/bin/VolumeManager.d.ts.map +0 -1
  56. package/bin/VolumeManager.js +0 -175
  57. package/bin/VolumeManager.js.map +0 -1
  58. package/bin/index.d.ts +0 -14
  59. package/bin/index.d.ts.map +0 -1
  60. package/bin/index.js +0 -30
  61. package/bin/index.js.map +0 -1
  62. package/bin/internals/GroupCoordinatorState.d.ts +0 -93
  63. package/bin/internals/GroupCoordinatorState.d.ts.map +0 -1
  64. package/bin/internals/GroupCoordinatorState.js +0 -405
  65. package/bin/internals/GroupCoordinatorState.js.map +0 -1
  66. package/bin/internals/GroupPlaybackPosition.d.ts +0 -67
  67. package/bin/internals/GroupPlaybackPosition.d.ts.map +0 -1
  68. package/bin/internals/GroupPlaybackPosition.js +0 -167
  69. package/bin/internals/GroupPlaybackPosition.js.map +0 -1
  70. package/bin/internals/GroupPlaybackTrack.d.ts +0 -46
  71. package/bin/internals/GroupPlaybackTrack.d.ts.map +0 -1
  72. package/bin/internals/GroupPlaybackTrack.js +0 -122
  73. package/bin/internals/GroupPlaybackTrack.js.map +0 -1
  74. package/bin/internals/GroupPlaybackTrackData.d.ts +0 -40
  75. package/bin/internals/GroupPlaybackTrackData.d.ts.map +0 -1
  76. package/bin/internals/GroupPlaybackTrackData.js +0 -70
  77. package/bin/internals/GroupPlaybackTrackData.js.map +0 -1
  78. package/bin/internals/GroupTransportState.d.ts +0 -49
  79. package/bin/internals/GroupTransportState.d.ts.map +0 -1
  80. package/bin/internals/GroupTransportState.js +0 -112
  81. package/bin/internals/GroupTransportState.js.map +0 -1
  82. package/bin/internals/consts.d.ts +0 -73
  83. package/bin/internals/consts.d.ts.map +0 -1
  84. package/bin/internals/consts.js +0 -82
  85. package/bin/internals/consts.js.map +0 -1
  86. package/bin/internals/index.d.ts +0 -11
  87. package/bin/internals/index.d.ts.map +0 -1
  88. package/bin/internals/index.js +0 -27
  89. package/bin/internals/index.js.map +0 -1
package/README.md CHANGED
@@ -11,15 +11,13 @@ You can find our API reference documentation at [aka.ms/livesharedocs](https://a
11
11
  To add the latest version of the SDK to your application using NPM:
12
12
 
13
13
  ```bash
14
- npm install @microsoft/live-share --save
15
- npm install @microsoft/live-share-media --save
14
+ npm install fluid-framework @fluidframework/azure-client @microsoft/live-share @microsoft/live-share-media --save
16
15
  ```
17
16
 
18
17
  or using [Yarn](https://yarnpkg.com/):
19
18
 
20
19
  ```bash
21
- yarn add @microsoft/live-share
22
- yarn add @microsoft/live-share-media
20
+ yarn add fluid-framework @fluidframework/azure-client @microsoft/live-share @microsoft/live-share-media
23
21
  ```
24
22
 
25
23
  ## Building package
@@ -115,6 +113,7 @@ The Live Share SDK contains dependencies for [@microsoft/teams-js](https://www.n
115
113
 
116
114
  | @microsoft/live-share | @microsoft/teams-js | fluid-framework | @microsoft/live-share-\* | @fluidframework/azure-client | @microsoft/TeamsFx | @microsoft/TeamsFx-react |
117
115
  | --------------------- | -------------------- | --------------- | -------------------------- | ---------------------------- | ------------------------------- | ------------------------------- |
116
+ | 1.0.0-preview.11 | ^2.11.0 | ^1.2.3 | 1.0.0-preview.11 (optional) | ^1.0.0 (optional) | ^2.5.0 (optional) | ^2.5.0 (optional) |
118
117
  | 1.0.0-preview.10 | ^2.10.1 | ~1.2.3 | 1.0.0-preview.10 (optional) | ~1.0.2 (optional) | ^2.5.0 (optional) | ^2.5.0 (optional) |
119
118
  | 1.0.0-preview.8 | ^2.5.0 | ~1.2.3 | 1.0.0-preview.10 (optional) | ~1.0.2 (optional) | ^2.5.0 (optional) | ^2.5.0 (optional) |
120
119
  | 1.0.0-preview.3 | 2.0.0-experimental.1 | ~1.2.3 | 1.0.0-preview.3 (optional) | ~1.0.2 (optional) | 2.0.0-experimental.0 (optional) | 2.0.0-experimental.0 (optional) |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@microsoft/live-share-media",
3
- "version": "1.0.0-preview.10",
3
+ "version": "1.0.0-preview.11",
4
4
  "description": "Live Share classes that synchronize media playback across clients.",
5
5
  "author": "Microsoft",
6
6
  "license": "SEE LICENSE IN LICENSE",
@@ -13,19 +13,21 @@
13
13
  "test:debug": "ts-mocha src/**/*.spec.ts --inspect-brk",
14
14
  "test:coverage": "nyc --reporter=html --reporter=text --reporter=text-summary npm test"
15
15
  },
16
- "dependencies": {
17
- "@microsoft/live-share": "1.0.0-preview.10",
18
- "fluid-framework": "~1.2.3"
19
- },
20
16
  "devDependencies": {
17
+ "@microsoft/live-share": "1.0.0-preview.11",
21
18
  "@types/assert": "^1.5.6",
22
19
  "@types/mocha": "^10.0.1",
23
20
  "@types/node": "^18.11.18",
21
+ "fluid-framework": "^1.3.6",
24
22
  "mocha": "^10.2.0",
25
23
  "nyc": "^15.1.0",
26
24
  "ts-mocha": "^10.0.0",
27
25
  "typescript": "^4.6.4"
28
26
  },
27
+ "peerDependencies": {
28
+ "@microsoft/live-share": "1.0.0-preview.11",
29
+ "fluid-framework": "^1.2.3"
30
+ },
29
31
  "repository": {
30
32
  "directory": "packages/live-share-media",
31
33
  "type": "git",
@@ -10,6 +10,7 @@ import {
10
10
  TimeInterval,
11
11
  IRuntimeSignaler,
12
12
  LiveTelemetryLogger,
13
+ LiveShareClient,
13
14
  } from "@microsoft/live-share";
14
15
  import EventEmitter from "events";
15
16
  import {
@@ -468,7 +469,7 @@ export class GroupCoordinatorState extends EventEmitter {
468
469
  );
469
470
  this._lastStateChange = event.playbackState;
470
471
  this._lastStateChangeTime =
471
- LiveEvent.getTimestamp();
472
+ LiveShareClient.getTimestamp();
472
473
  }
473
474
  break;
474
475
  }
@@ -494,7 +495,7 @@ export class GroupCoordinatorState extends EventEmitter {
494
495
  public async syncLocalMediaSession(): Promise<void> {
495
496
  // Skip further syncs if we're waiting or in a "soft suspension".
496
497
  const softSuspensionDelta =
497
- LiveEvent.getTimestamp() - this._lastStateChangeTime;
498
+ LiveShareClient.getTimestamp() - this._lastStateChangeTime;
498
499
  if (!this.isWaiting && softSuspensionDelta >= 1000) {
499
500
  let { metadata, trackData, positionState, playbackState } =
500
501
  this._getMediaPlayerState();
@@ -4,9 +4,9 @@
4
4
  */
5
5
 
6
6
  import {
7
- LiveEvent,
8
7
  IRuntimeSignaler,
9
8
  TimeInterval,
9
+ LiveShareClient,
10
10
  } from "@microsoft/live-share";
11
11
  import { GroupTransportState } from "./GroupTransportState";
12
12
  import { GroupPlaybackTrackEvents } from "./GroupPlaybackTrack";
@@ -129,7 +129,7 @@ export class GroupPlaybackPosition {
129
129
  */
130
130
  public get maxPosition(): number {
131
131
  if (this._transportState.playbackState == "playing") {
132
- const now = LiveEvent.getTimestamp();
132
+ const now = LiveShareClient.getTimestamp();
133
133
  const projected =
134
134
  this._transportState.startPosition +
135
135
  (now - this._transportState.timestamp) / 1000;
@@ -162,7 +162,7 @@ export class GroupPlaybackPosition {
162
162
  projectedPosition: number
163
163
  ) => void
164
164
  ): void {
165
- const now = LiveEvent.getTimestamp();
165
+ const now = LiveShareClient.getTimestamp();
166
166
  const ignoreBefore = now - this._updateInterval.milliseconds * 2;
167
167
  const shouldProject = !this._transportState.track.metadata?.liveStream;
168
168
  this._positions.forEach((value, key) => {
@@ -3,7 +3,7 @@
3
3
  * Licensed under the Microsoft Live Share SDK License.
4
4
  */
5
5
 
6
- import { IEvent, LiveEvent } from "@microsoft/live-share";
6
+ import { IEvent, LiveShareClient } from "@microsoft/live-share";
7
7
  import EventEmitter from "events";
8
8
  import { IMediaPlayerState } from "../LiveMediaSessionCoordinator";
9
9
  import {
@@ -136,7 +136,7 @@ export class GroupTransportState extends EventEmitter {
136
136
  seekTime: state.startPosition,
137
137
  });
138
138
  } else if (state.playbackState == "playing") {
139
- const now = LiveEvent.getTimestamp();
139
+ const now = LiveShareClient.getTimestamp();
140
140
  const projectedPosition =
141
141
  state.startPosition + (now - state.timestamp) / 1000;
142
142
  this.emit(GroupTransportStateEvents.transportStateChange, {
@@ -1,102 +0,0 @@
1
- /**
2
- * Copyright (c) Microsoft Corporation. All rights reserved.
3
- * Licensed under the Microsoft Live Share SDK License.
4
- */
5
- import { DataObject, DataObjectFactory } from '@fluidframework/aqueduct';
6
- import { EphemeralTelemetryLogger, UserMeetingRole } from '@microsoft/live-share';
7
- import { MediaPlayerSynchronizer } from './MediaPlayerSynchronizer';
8
- import { ExtendedMediaSessionAction } from './MediaSessionExtensions';
9
- import { EphemeralMediaSessionCoordinator, IMediaPlayerState } from './EphemeralMediaSessionCoordinator';
10
- import { MediaSessionActionThrottler } from './MediaSessionActionThrottler';
11
- import { IMediaPlayer } from './IMediaPlayer';
12
- /**
13
- * Ephemeral fluid object that synchronizes media playback across multiple clients.
14
- */
15
- export declare class EphemeralMediaSession extends DataObject {
16
- private _actionThrottler;
17
- private _logger?;
18
- private _requestPlayerStateHandler?;
19
- private _coordinator?;
20
- private readonly _actionHandlers;
21
- private _synchronizing?;
22
- private _updateTimer;
23
- private _lastUpdateTime;
24
- /**
25
- * The objects fluid type name.
26
- */
27
- static readonly TypeName = "@microsoft/fluid-media:SharedMediaSession";
28
- /**
29
- * The objects fluid type factory.
30
- */
31
- static readonly factory: DataObjectFactory<EphemeralMediaSession, import("@fluidframework/aqueduct").DataObjectTypes>;
32
- /**
33
- * Extension point that lets applications replace the default logic for throttling the sessions
34
- * local sync behavior.
35
- *
36
- * @remarks
37
- * The `EphemeralMediaCoordinator` is fairly aggressive at wanting to keep the local media player
38
- * in sync with the rest of the group. This aggressiveness can result in the coordinator sending
39
- * new sync actions before the local player has finished responding to the previous sync action.
40
- * The `ActionThrottler` gives apps fine grain control over how aggressive they want sync to be.
41
- *
42
- * By default, a `RepeatedAction` throttler is used which prevents the same sync action from
43
- * being sent within an adjustable time period.
44
- */
45
- get actionThrottler(): MediaSessionActionThrottler;
46
- set actionThrottler(value: MediaSessionActionThrottler);
47
- /**
48
- * Returns true if the object has been initialized.
49
- */
50
- get isInitialized(): boolean;
51
- /**
52
- * @deprecated isInitialized should be used instead
53
- * Returns true if the object has been initialized.
54
- */
55
- get isStarted(): boolean;
56
- /**
57
- * The group coordinator for the session.
58
- */
59
- get coordinator(): EphemeralMediaSessionCoordinator;
60
- /**
61
- * Returns the logger used by the session and coordinator.
62
- *
63
- * @remarks
64
- * This is used by the `MediaPlayerSynchronizer` to log events.
65
- */
66
- get logger(): EphemeralTelemetryLogger;
67
- /**
68
- * initialize the object.
69
- * @param acceptTransportChangesFrom Optional. List of roles allowed to group transport
70
- * operations like play/pause/seek/setTrack.
71
- */
72
- initialize(acceptTransportChangesFrom?: UserMeetingRole[]): Promise<void>;
73
- /**
74
- * @deprecated initialize should be used instead
75
- * initialize the object.
76
- * @param acceptTransportChangesFrom Optional. List of roles allowed to group transport
77
- * operations like play/pause/seek/setTrack.
78
- */
79
- start(acceptTransportChangesFrom?: UserMeetingRole[]): Promise<void>;
80
- /**
81
- * Registers an action handler with the session.
82
- * @param action Name of the action to register a handler for.
83
- * @param handler Function called when the action is triggered.
84
- */
85
- setActionHandler(action: ExtendedMediaSessionAction, handler: MediaSessionActionHandler | null): void;
86
- /**
87
- * Registers a handler that will be queried anytime the group coordinate needs to know the
88
- * local players transport state and position.
89
- */
90
- setRequestPlayerStateHandler(handler: () => IMediaPlayerState): void;
91
- /**
92
- * Begins synchronizing the playback of a media element.
93
- * @param player Something that "looks like" and HTML Media Element.
94
- * @returns A new synchronizer instance. Call `synchronizer.end()` to stop synchronizing the elements playback.
95
- */
96
- synchronize(player: IMediaPlayer): MediaPlayerSynchronizer;
97
- protected hasInitialized(): Promise<void>;
98
- private checkWaitPointHit;
99
- private getCurrentPlayerState;
100
- private dispatchAction;
101
- }
102
- //# sourceMappingURL=EphemeralMediaSession.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"EphemeralMediaSession.d.ts","sourceRoot":"","sources":["../src/EphemeralMediaSession.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AACzE,OAAO,EAAE,wBAAwB,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAClF,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AAEpE,OAAO,EAAiC,0BAA0B,EAAqC,MAAM,0BAA0B,CAAC;AACxI,OAAO,EAAE,gCAAgC,EAAE,iBAAiB,EAAE,MAAM,oCAAoC,CAAC;AACzG,OAAO,EAAE,2BAA2B,EAAE,MAAM,+BAA+B,CAAC;AAE5E,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE9C;;GAEG;AACF,qBAAa,qBAAsB,SAAQ,UAAU;IAClD,OAAO,CAAC,gBAAgB,CAA8D;IACtF,OAAO,CAAC,OAAO,CAA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**
3
- * Copyright (c) Microsoft Corporation. All rights reserved.
4
- * Licensed under the Microsoft Live Share SDK License.
5
- */
6
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
7
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
8
- return new (P || (P = Promise))(function (resolve, reject) {
9
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
10
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
11
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
12
- step((generator = generator.apply(thisArg, _arguments || [])).next());
13
- });
14
- };
15
- Object.defineProperty(exports, "__esModule", { value: true });
16
- exports.EphemeralMediaSession = void 0;
17
- const aqueduct_1 = require("@fluidframework/aqueduct");
18
- const live_share_1 = require("@microsoft/live-share");
19
- const MediaPlayerSynchronizer_1 = require("./MediaPlayerSynchronizer");
20
- const internals_1 = require("./internals");
21
- const MediaSessionExtensions_1 = require("./MediaSessionExtensions");
22
- const EphemeralMediaSessionCoordinator_1 = require("./EphemeralMediaSessionCoordinator");
23
- const RepeatedActionThrottler_1 = require("./RepeatedActionThrottler");
24
- /**
25
- * Ephemeral fluid object that synchronizes media playback across multiple clients.
26
- */
27
- class EphemeralMediaSession extends aqueduct_1.DataObject {
28
- constructor() {
29
- super(...arguments);
30
- this._actionThrottler = new RepeatedActionThrottler_1.RepeatedActionThrottler();
31
- this._actionHandlers = new Map();
32
- this._lastUpdateTime = 0;
33
- }
34
- /**
35
- * Extension point that lets applications replace the default logic for throttling the sessions
36
- * local sync behavior.
37
- *
38
- * @remarks
39
- * The `EphemeralMediaCoordinator` is fairly aggressive at wanting to keep the local media player
40
- * in sync with the rest of the group. This aggressiveness can result in the coordinator sending
41
- * new sync actions before the local player has finished responding to the previous sync action.
42
- * The `ActionThrottler` gives apps fine grain control over how aggressive they want sync to be.
43
- *
44
- * By default, a `RepeatedAction` throttler is used which prevents the same sync action from
45
- * being sent within an adjustable time period.
46
- */
47
- get actionThrottler() {
48
- return this._actionThrottler;
49
- }
50
- set actionThrottler(value) {
51
- this._actionThrottler = value;
52
- }
53
- /**
54
- * Returns true if the object has been initialized.
55
- */
56
- get isInitialized() {
57
- return this.coordinator.isInitialized;
58
- }
59
- /**
60
- * @deprecated isInitialized should be used instead
61
- * Returns true if the object has been initialized.
62
- */
63
- get isStarted() {
64
- return this.isInitialized;
65
- }
66
- /**
67
- * The group coordinator for the session.
68
- */
69
- get coordinator() {
70
- return this._coordinator;
71
- }
72
- /**
73
- * Returns the logger used by the session and coordinator.
74
- *
75
- * @remarks
76
- * This is used by the `MediaPlayerSynchronizer` to log events.
77
- */
78
- get logger() {
79
- return this._logger;
80
- }
81
- /**
82
- * initialize the object.
83
- * @param acceptTransportChangesFrom Optional. List of roles allowed to group transport
84
- * operations like play/pause/seek/setTrack.
85
- */
86
- initialize(acceptTransportChangesFrom) {
87
- return this.coordinator.initialize(acceptTransportChangesFrom);
88
- }
89
- /**
90
- * @deprecated initialize should be used instead
91
- * initialize the object.
92
- * @param acceptTransportChangesFrom Optional. List of roles allowed to group transport
93
- * operations like play/pause/seek/setTrack.
94
- */
95
- start(acceptTransportChangesFrom) {
96
- return this.initialize(acceptTransportChangesFrom);
97
- }
98
- /**
99
- * Registers an action handler with the session.
100
- * @param action Name of the action to register a handler for.
101
- * @param handler Function called when the action is triggered.
102
- */
103
- setActionHandler(action, handler) {
104
- if (handler) {
105
- // add handler
106
- this._actionHandlers.set(action, handler);
107
- }
108
- else if (this._actionHandlers.has(action)) {
109
- // remove handler
110
- this._actionHandlers.delete(action);
111
- }
112
- }
113
- /**
114
- * Registers a handler that will be queried anytime the group coordinate needs to know the
115
- * local players transport state and position.
116
- */
117
- setRequestPlayerStateHandler(handler) {
118
- this._requestPlayerStateHandler = handler;
119
- }
120
- /**
121
- * Begins synchronizing the playback of a media element.
122
- * @param player Something that "looks like" and HTML Media Element.
123
- * @returns A new synchronizer instance. Call `synchronizer.end()` to stop synchronizing the elements playback.
124
- */
125
- synchronize(player) {
126
- // A session can only synchronize one player at a time
127
- if (this._synchronizing) {
128
- this._synchronizing.end();
129
- }
130
- // Start position update timer
131
- if (!this._updateTimer) {
132
- this.logger.sendTelemetryEvent(internals_1.TelemetryEvents.MediaSession.BeginPositionUpdateTimer);
133
- this._updateTimer = setInterval(() => {
134
- // Get current state
135
- const state = this.getCurrentPlayerState();
136
- // Check for hit wait point
137
- this.checkWaitPointHit(state);
138
- // Send position update if interval hit
139
- const now = new Date().getTime();
140
- const delta = (now - this._lastUpdateTime) / 1000;
141
- if (this.coordinator.isInitialized && delta >= this.coordinator.positionUpdateInterval) {
142
- this._lastUpdateTime = now;
143
- this.coordinator.sendPositionUpdate(state);
144
- }
145
- }, 500);
146
- }
147
- return new MediaPlayerSynchronizer_1.MediaPlayerSynchronizer(player, this, () => {
148
- this._synchronizing = undefined;
149
- });
150
- }
151
- hasInitialized() {
152
- return __awaiter(this, void 0, void 0, function* () {
153
- this._logger = new live_share_1.EphemeralTelemetryLogger(this.runtime);
154
- // Create coordinator and listen for triggered actions
155
- this._coordinator = new EphemeralMediaSessionCoordinator_1.EphemeralMediaSessionCoordinator(this.runtime, () => this.getCurrentPlayerState());
156
- this._coordinator.on(MediaSessionExtensions_1.MediaSessionCoordinatorEvents.triggeraction, (event) => {
157
- // Pre-process actions
158
- const details = event.details;
159
- const seekTime = typeof details.seekTime == 'number' ? details.seekTime : -1;
160
- switch (details.action) {
161
- case 'play':
162
- this.logger.sendTelemetryEvent(internals_1.TelemetryEvents.MediaSession.PlayAction, null, { position: seekTime });
163
- break;
164
- case 'pause':
165
- this.logger.sendTelemetryEvent(internals_1.TelemetryEvents.MediaSession.PauseAction, null, { position: seekTime });
166
- break;
167
- case 'seekto':
168
- this.logger.sendTelemetryEvent(internals_1.TelemetryEvents.MediaSession.SeekToAction, null, { position: seekTime });
169
- break;
170
- case 'settrack':
171
- this.logger.sendTelemetryEvent(internals_1.TelemetryEvents.MediaSession.SetTrackAction);
172
- break;
173
- case 'datachange':
174
- this.logger.sendTelemetryEvent(internals_1.TelemetryEvents.MediaSession.DataChangeAction);
175
- break;
176
- case 'catchup':
177
- // Default to seekto if catchup not implemented
178
- this.logger.sendTelemetryEvent(internals_1.TelemetryEvents.MediaSession.CatchUpAction, null, { position: seekTime });
179
- if (!this._actionHandlers.has('catchup')) {
180
- details.action = 'seekto';
181
- }
182
- break;
183
- }
184
- // Dispatch action
185
- this.dispatchAction(details);
186
- });
187
- });
188
- }
189
- checkWaitPointHit(state) {
190
- // Was a wait point hit?
191
- if (state.positionState && this.coordinator.isInitialized) {
192
- const waitPoint = this.coordinator.findNextWaitPoint();
193
- if (waitPoint && state.positionState.position != undefined && state.positionState.position >= waitPoint.position) {
194
- // Ensure handler registered
195
- if (!this._actionHandlers.has('wait')) {
196
- throw new Error(`SharedMediaSession: wait point hit but no 'wait' action registered.`);
197
- }
198
- // Begin suspension for wait point
199
- const suspension = this.coordinator.beginSuspension(waitPoint);
200
- this.dispatchAction({ action: 'wait', suspension: suspension });
201
- }
202
- }
203
- }
204
- getCurrentPlayerState() {
205
- if (!this._requestPlayerStateHandler) {
206
- throw new Error(`SharedMediaSession: no getPlayerState callback configured.`);
207
- }
208
- return this._requestPlayerStateHandler();
209
- }
210
- dispatchAction(details) {
211
- if (this._actionHandlers.has(details.action)) {
212
- const handler = this._actionHandlers.get(details.action);
213
- this._actionThrottler.throttled(details, handler);
214
- }
215
- }
216
- }
217
- exports.EphemeralMediaSession = EphemeralMediaSession;
218
- /**
219
- * The objects fluid type name.
220
- */
221
- EphemeralMediaSession.TypeName = `@microsoft/fluid-media:SharedMediaSession`;
222
- /**
223
- * The objects fluid type factory.
224
- */
225
- EphemeralMediaSession.factory = new aqueduct_1.DataObjectFactory(EphemeralMediaSession.TypeName, EphemeralMediaSession, [], {});
226
- //# sourceMappingURL=EphemeralMediaSession.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"EphemeralMediaSession.js","sourceRoot":"","sources":["../src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