@microsoft/live-share-media 1.4.0 → 1.4.2

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 (293) hide show
  1. package/bin/LiveMediaSessionCoordinator.d.ts +0 -1
  2. package/bin/LiveMediaSessionCoordinator.d.ts.map +1 -1
  3. package/bin/MediaPlayerSynchronizer.d.ts +0 -1
  4. package/bin/MediaPlayerSynchronizer.d.ts.map +1 -1
  5. package/bin/cjs/IMediaPlayer.d.ts +21 -0
  6. package/bin/cjs/IMediaPlayer.d.ts.map +1 -0
  7. package/bin/cjs/IMediaPlayer.js +7 -0
  8. package/bin/cjs/IMediaPlayer.js.map +1 -0
  9. package/bin/cjs/LiveMediaSession.d.ts +97 -0
  10. package/bin/cjs/LiveMediaSession.d.ts.map +1 -0
  11. package/bin/cjs/LiveMediaSession.js +261 -0
  12. package/bin/cjs/LiveMediaSession.js.map +1 -0
  13. package/bin/cjs/LiveMediaSessionCoordinator.d.ts +304 -0
  14. package/bin/cjs/LiveMediaSessionCoordinator.d.ts.map +1 -0
  15. package/bin/cjs/LiveMediaSessionCoordinator.js +560 -0
  16. package/bin/cjs/LiveMediaSessionCoordinator.js.map +1 -0
  17. package/bin/cjs/LiveMediaSessionCoordinatorSuspension.d.ts +20 -0
  18. package/bin/cjs/LiveMediaSessionCoordinatorSuspension.d.ts.map +1 -0
  19. package/bin/cjs/LiveMediaSessionCoordinatorSuspension.js +28 -0
  20. package/bin/cjs/LiveMediaSessionCoordinatorSuspension.js.map +1 -0
  21. package/bin/cjs/MediaPlayerSynchronizer.d.ts +204 -0
  22. package/bin/cjs/MediaPlayerSynchronizer.d.ts.map +1 -0
  23. package/bin/cjs/MediaPlayerSynchronizer.js +574 -0
  24. package/bin/cjs/MediaPlayerSynchronizer.js.map +1 -0
  25. package/bin/cjs/MediaSessionActionThrottler.d.ts +12 -0
  26. package/bin/cjs/MediaSessionActionThrottler.d.ts.map +1 -0
  27. package/bin/cjs/MediaSessionActionThrottler.js +14 -0
  28. package/bin/cjs/MediaSessionActionThrottler.js.map +1 -0
  29. package/bin/cjs/MediaSessionExtensions.d.ts +177 -0
  30. package/bin/cjs/MediaSessionExtensions.d.ts.map +1 -0
  31. package/bin/cjs/MediaSessionExtensions.js +26 -0
  32. package/bin/cjs/MediaSessionExtensions.js.map +1 -0
  33. package/bin/cjs/RepeatedActionThrottler.d.ts +20 -0
  34. package/bin/cjs/RepeatedActionThrottler.d.ts.map +1 -0
  35. package/bin/cjs/RepeatedActionThrottler.js +63 -0
  36. package/bin/cjs/RepeatedActionThrottler.js.map +1 -0
  37. package/bin/cjs/VolumeManager.d.ts +84 -0
  38. package/bin/cjs/VolumeManager.d.ts.map +1 -0
  39. package/bin/cjs/VolumeManager.js +175 -0
  40. package/bin/cjs/VolumeManager.js.map +1 -0
  41. package/bin/cjs/index.d.ts +14 -0
  42. package/bin/cjs/index.d.ts.map +1 -0
  43. package/bin/cjs/index.js +30 -0
  44. package/bin/cjs/index.js.map +1 -0
  45. package/bin/cjs/internals/GroupCoordinatorState.d.ts +110 -0
  46. package/bin/cjs/internals/GroupCoordinatorState.d.ts.map +1 -0
  47. package/bin/cjs/internals/GroupCoordinatorState.js +516 -0
  48. package/bin/cjs/internals/GroupCoordinatorState.js.map +1 -0
  49. package/bin/cjs/internals/GroupPlaybackPosition.d.ts +71 -0
  50. package/bin/cjs/internals/GroupPlaybackPosition.d.ts.map +1 -0
  51. package/bin/cjs/internals/GroupPlaybackPosition.js +170 -0
  52. package/bin/cjs/internals/GroupPlaybackPosition.js.map +1 -0
  53. package/bin/cjs/internals/GroupPlaybackRate.d.ts +38 -0
  54. package/bin/cjs/internals/GroupPlaybackRate.d.ts.map +1 -0
  55. package/bin/cjs/internals/GroupPlaybackRate.js +59 -0
  56. package/bin/cjs/internals/GroupPlaybackRate.js.map +1 -0
  57. package/bin/cjs/internals/GroupPlaybackTrack.d.ts +45 -0
  58. package/bin/cjs/internals/GroupPlaybackTrack.d.ts.map +1 -0
  59. package/bin/cjs/internals/GroupPlaybackTrack.js +122 -0
  60. package/bin/cjs/internals/GroupPlaybackTrack.js.map +1 -0
  61. package/bin/cjs/internals/GroupPlaybackTrackData.d.ts +40 -0
  62. package/bin/cjs/internals/GroupPlaybackTrackData.d.ts.map +1 -0
  63. package/bin/cjs/internals/GroupPlaybackTrackData.js +70 -0
  64. package/bin/cjs/internals/GroupPlaybackTrackData.js.map +1 -0
  65. package/bin/cjs/internals/GroupTransportState.d.ts +52 -0
  66. package/bin/cjs/internals/GroupTransportState.d.ts.map +1 -0
  67. package/bin/cjs/internals/GroupTransportState.js +120 -0
  68. package/bin/cjs/internals/GroupTransportState.js.map +1 -0
  69. package/bin/cjs/internals/PriorityTimeInterval.d.ts +33 -0
  70. package/bin/cjs/internals/PriorityTimeInterval.d.ts.map +1 -0
  71. package/bin/cjs/internals/PriorityTimeInterval.js +45 -0
  72. package/bin/cjs/internals/PriorityTimeInterval.js.map +1 -0
  73. package/bin/cjs/internals/consts.d.ts +83 -0
  74. package/bin/cjs/internals/consts.d.ts.map +1 -0
  75. package/bin/cjs/internals/consts.js +92 -0
  76. package/bin/cjs/internals/consts.js.map +1 -0
  77. package/bin/cjs/internals/errors.d.ts +17 -0
  78. package/bin/cjs/internals/errors.d.ts.map +1 -0
  79. package/bin/cjs/internals/errors.js +34 -0
  80. package/bin/cjs/internals/errors.js.map +1 -0
  81. package/bin/cjs/internals/interfaces.d.ts +23 -0
  82. package/bin/cjs/internals/interfaces.d.ts.map +1 -0
  83. package/bin/cjs/internals/interfaces.js +3 -0
  84. package/bin/cjs/internals/interfaces.js.map +1 -0
  85. package/bin/cjs/package.json +1 -0
  86. package/bin/esm/IMediaPlayer.d.ts +21 -0
  87. package/bin/esm/IMediaPlayer.d.ts.map +1 -0
  88. package/bin/esm/IMediaPlayer.js +6 -0
  89. package/bin/esm/IMediaPlayer.js.map +1 -0
  90. package/bin/esm/LiveMediaSession.d.ts +97 -0
  91. package/bin/esm/LiveMediaSession.d.ts.map +1 -0
  92. package/bin/esm/LiveMediaSession.js +257 -0
  93. package/bin/esm/LiveMediaSession.js.map +1 -0
  94. package/bin/esm/LiveMediaSessionCoordinator.d.ts +304 -0
  95. package/bin/esm/LiveMediaSessionCoordinator.d.ts.map +1 -0
  96. package/bin/esm/LiveMediaSessionCoordinator.js +556 -0
  97. package/bin/esm/LiveMediaSessionCoordinator.js.map +1 -0
  98. package/bin/esm/LiveMediaSessionCoordinatorSuspension.d.ts +20 -0
  99. package/bin/esm/LiveMediaSessionCoordinatorSuspension.d.ts.map +1 -0
  100. package/bin/esm/LiveMediaSessionCoordinatorSuspension.js +24 -0
  101. package/bin/esm/LiveMediaSessionCoordinatorSuspension.js.map +1 -0
  102. package/bin/esm/MediaPlayerSynchronizer.d.ts +204 -0
  103. package/bin/esm/MediaPlayerSynchronizer.d.ts.map +1 -0
  104. package/bin/esm/MediaPlayerSynchronizer.js +570 -0
  105. package/bin/esm/MediaPlayerSynchronizer.js.map +1 -0
  106. package/bin/esm/MediaSessionActionThrottler.d.ts +12 -0
  107. package/bin/esm/MediaSessionActionThrottler.d.ts.map +1 -0
  108. package/bin/esm/MediaSessionActionThrottler.js +10 -0
  109. package/bin/esm/MediaSessionActionThrottler.js.map +1 -0
  110. package/bin/esm/MediaSessionExtensions.d.ts +177 -0
  111. package/bin/esm/MediaSessionExtensions.d.ts.map +1 -0
  112. package/bin/esm/MediaSessionExtensions.js +23 -0
  113. package/bin/esm/MediaSessionExtensions.js.map +1 -0
  114. package/bin/esm/RepeatedActionThrottler.d.ts +20 -0
  115. package/bin/esm/RepeatedActionThrottler.d.ts.map +1 -0
  116. package/bin/esm/RepeatedActionThrottler.js +59 -0
  117. package/bin/esm/RepeatedActionThrottler.js.map +1 -0
  118. package/bin/esm/VolumeManager.d.ts +84 -0
  119. package/bin/esm/VolumeManager.d.ts.map +1 -0
  120. package/bin/esm/VolumeManager.js +171 -0
  121. package/bin/esm/VolumeManager.js.map +1 -0
  122. package/bin/esm/index.d.ts +14 -0
  123. package/bin/esm/index.d.ts.map +1 -0
  124. package/bin/esm/index.js +14 -0
  125. package/bin/esm/index.js.map +1 -0
  126. package/bin/esm/internals/GroupCoordinatorState.d.ts +110 -0
  127. package/bin/esm/internals/GroupCoordinatorState.d.ts.map +1 -0
  128. package/bin/esm/internals/GroupCoordinatorState.js +512 -0
  129. package/bin/esm/internals/GroupCoordinatorState.js.map +1 -0
  130. package/bin/esm/internals/GroupPlaybackPosition.d.ts +71 -0
  131. package/bin/esm/internals/GroupPlaybackPosition.d.ts.map +1 -0
  132. package/bin/esm/internals/GroupPlaybackPosition.js +166 -0
  133. package/bin/esm/internals/GroupPlaybackPosition.js.map +1 -0
  134. package/bin/esm/internals/GroupPlaybackRate.d.ts +38 -0
  135. package/bin/esm/internals/GroupPlaybackRate.d.ts.map +1 -0
  136. package/bin/esm/internals/GroupPlaybackRate.js +55 -0
  137. package/bin/esm/internals/GroupPlaybackRate.js.map +1 -0
  138. package/bin/esm/internals/GroupPlaybackTrack.d.ts +45 -0
  139. package/bin/esm/internals/GroupPlaybackTrack.d.ts.map +1 -0
  140. package/bin/esm/internals/GroupPlaybackTrack.js +118 -0
  141. package/bin/esm/internals/GroupPlaybackTrack.js.map +1 -0
  142. package/bin/esm/internals/GroupPlaybackTrackData.d.ts +40 -0
  143. package/bin/esm/internals/GroupPlaybackTrackData.d.ts.map +1 -0
  144. package/bin/esm/internals/GroupPlaybackTrackData.js +66 -0
  145. package/bin/esm/internals/GroupPlaybackTrackData.js.map +1 -0
  146. package/bin/esm/internals/GroupTransportState.d.ts +52 -0
  147. package/bin/esm/internals/GroupTransportState.d.ts.map +1 -0
  148. package/bin/esm/internals/GroupTransportState.js +116 -0
  149. package/bin/esm/internals/GroupTransportState.js.map +1 -0
  150. package/bin/esm/internals/PriorityTimeInterval.d.ts +33 -0
  151. package/bin/esm/internals/PriorityTimeInterval.d.ts.map +1 -0
  152. package/bin/esm/internals/PriorityTimeInterval.js +41 -0
  153. package/bin/esm/internals/PriorityTimeInterval.js.map +1 -0
  154. package/bin/esm/internals/consts.d.ts +83 -0
  155. package/bin/esm/internals/consts.d.ts.map +1 -0
  156. package/bin/esm/internals/consts.js +89 -0
  157. package/bin/esm/internals/consts.js.map +1 -0
  158. package/bin/esm/internals/errors.d.ts +17 -0
  159. package/bin/esm/internals/errors.d.ts.map +1 -0
  160. package/bin/esm/internals/errors.js +29 -0
  161. package/bin/esm/internals/errors.js.map +1 -0
  162. package/bin/esm/internals/interfaces.d.ts +23 -0
  163. package/bin/esm/internals/interfaces.d.ts.map +1 -0
  164. package/bin/esm/internals/interfaces.js +2 -0
  165. package/bin/esm/internals/interfaces.js.map +1 -0
  166. package/bin/internals/GroupCoordinatorState.d.ts +0 -1
  167. package/bin/internals/GroupCoordinatorState.d.ts.map +1 -1
  168. package/bin/internals/GroupPlaybackRate.d.ts +0 -1
  169. package/bin/internals/GroupPlaybackRate.d.ts.map +1 -1
  170. package/bin/internals/GroupPlaybackTrack.d.ts +0 -1
  171. package/bin/internals/GroupPlaybackTrack.d.ts.map +1 -1
  172. package/bin/internals/GroupPlaybackTrackData.d.ts +0 -1
  173. package/bin/internals/GroupPlaybackTrackData.d.ts.map +1 -1
  174. package/bin/internals/GroupTransportState.d.ts +0 -1
  175. package/bin/internals/GroupTransportState.d.ts.map +1 -1
  176. package/bin/test/IMediaPlayer.d.ts +21 -0
  177. package/bin/test/IMediaPlayer.d.ts.map +1 -0
  178. package/bin/test/IMediaPlayer.js +7 -0
  179. package/bin/test/IMediaPlayer.js.map +1 -0
  180. package/bin/test/LiveMediaSession.d.ts +97 -0
  181. package/bin/test/LiveMediaSession.d.ts.map +1 -0
  182. package/bin/test/LiveMediaSession.js +261 -0
  183. package/bin/test/LiveMediaSession.js.map +1 -0
  184. package/bin/test/LiveMediaSessionCoordinator.d.ts +304 -0
  185. package/bin/test/LiveMediaSessionCoordinator.d.ts.map +1 -0
  186. package/bin/test/LiveMediaSessionCoordinator.js +560 -0
  187. package/bin/test/LiveMediaSessionCoordinator.js.map +1 -0
  188. package/bin/test/LiveMediaSessionCoordinatorSuspension.d.ts +20 -0
  189. package/bin/test/LiveMediaSessionCoordinatorSuspension.d.ts.map +1 -0
  190. package/bin/test/LiveMediaSessionCoordinatorSuspension.js +28 -0
  191. package/bin/test/LiveMediaSessionCoordinatorSuspension.js.map +1 -0
  192. package/bin/test/MediaPlayerSynchronizer.d.ts +204 -0
  193. package/bin/test/MediaPlayerSynchronizer.d.ts.map +1 -0
  194. package/bin/test/MediaPlayerSynchronizer.js +574 -0
  195. package/bin/test/MediaPlayerSynchronizer.js.map +1 -0
  196. package/bin/test/MediaSessionActionThrottler.d.ts +12 -0
  197. package/bin/test/MediaSessionActionThrottler.d.ts.map +1 -0
  198. package/bin/test/MediaSessionActionThrottler.js +14 -0
  199. package/bin/test/MediaSessionActionThrottler.js.map +1 -0
  200. package/bin/test/MediaSessionExtensions.d.ts +177 -0
  201. package/bin/test/MediaSessionExtensions.d.ts.map +1 -0
  202. package/bin/test/MediaSessionExtensions.js +26 -0
  203. package/bin/test/MediaSessionExtensions.js.map +1 -0
  204. package/bin/test/RepeatedActionThrottler.d.ts +20 -0
  205. package/bin/test/RepeatedActionThrottler.d.ts.map +1 -0
  206. package/bin/test/RepeatedActionThrottler.js +63 -0
  207. package/bin/test/RepeatedActionThrottler.js.map +1 -0
  208. package/bin/test/VolumeManager.d.ts +84 -0
  209. package/bin/test/VolumeManager.d.ts.map +1 -0
  210. package/bin/test/VolumeManager.js +175 -0
  211. package/bin/test/VolumeManager.js.map +1 -0
  212. package/bin/test/index.d.ts +14 -0
  213. package/bin/test/index.d.ts.map +1 -0
  214. package/bin/test/index.js +30 -0
  215. package/bin/test/index.js.map +1 -0
  216. package/bin/test/internals/GroupCoordinatorState.d.ts +110 -0
  217. package/bin/test/internals/GroupCoordinatorState.d.ts.map +1 -0
  218. package/bin/test/internals/GroupCoordinatorState.js +516 -0
  219. package/bin/test/internals/GroupCoordinatorState.js.map +1 -0
  220. package/bin/test/internals/GroupPlaybackPosition.d.ts +71 -0
  221. package/bin/test/internals/GroupPlaybackPosition.d.ts.map +1 -0
  222. package/bin/test/internals/GroupPlaybackPosition.js +170 -0
  223. package/bin/test/internals/GroupPlaybackPosition.js.map +1 -0
  224. package/bin/test/internals/GroupPlaybackRate.d.ts +38 -0
  225. package/bin/test/internals/GroupPlaybackRate.d.ts.map +1 -0
  226. package/bin/test/internals/GroupPlaybackRate.js +59 -0
  227. package/bin/test/internals/GroupPlaybackRate.js.map +1 -0
  228. package/bin/test/internals/GroupPlaybackTrack.d.ts +45 -0
  229. package/bin/test/internals/GroupPlaybackTrack.d.ts.map +1 -0
  230. package/bin/test/internals/GroupPlaybackTrack.js +122 -0
  231. package/bin/test/internals/GroupPlaybackTrack.js.map +1 -0
  232. package/bin/test/internals/GroupPlaybackTrackData.d.ts +40 -0
  233. package/bin/test/internals/GroupPlaybackTrackData.d.ts.map +1 -0
  234. package/bin/test/internals/GroupPlaybackTrackData.js +70 -0
  235. package/bin/test/internals/GroupPlaybackTrackData.js.map +1 -0
  236. package/bin/test/internals/GroupTransportState.d.ts +52 -0
  237. package/bin/test/internals/GroupTransportState.d.ts.map +1 -0
  238. package/bin/test/internals/GroupTransportState.js +120 -0
  239. package/bin/test/internals/GroupTransportState.js.map +1 -0
  240. package/bin/test/internals/PriorityTimeInterval.d.ts +33 -0
  241. package/bin/test/internals/PriorityTimeInterval.d.ts.map +1 -0
  242. package/bin/test/internals/PriorityTimeInterval.js +45 -0
  243. package/bin/test/internals/PriorityTimeInterval.js.map +1 -0
  244. package/bin/test/internals/consts.d.ts +83 -0
  245. package/bin/test/internals/consts.d.ts.map +1 -0
  246. package/bin/test/internals/consts.js +92 -0
  247. package/bin/test/internals/consts.js.map +1 -0
  248. package/bin/test/internals/errors.d.ts +17 -0
  249. package/bin/test/internals/errors.d.ts.map +1 -0
  250. package/bin/test/internals/errors.js +34 -0
  251. package/bin/test/internals/errors.js.map +1 -0
  252. package/bin/test/internals/interfaces.d.ts +23 -0
  253. package/bin/test/internals/interfaces.d.ts.map +1 -0
  254. package/bin/test/internals/interfaces.js +3 -0
  255. package/bin/test/internals/interfaces.js.map +1 -0
  256. package/bin/test/package.json +1 -0
  257. package/bin/test/test/GroupPlaybackPosition.spec.d.ts +6 -0
  258. package/bin/test/test/GroupPlaybackPosition.spec.d.ts.map +1 -0
  259. package/bin/test/test/GroupPlaybackPosition.spec.js +315 -0
  260. package/bin/test/test/GroupPlaybackPosition.spec.js.map +1 -0
  261. package/bin/test/test/GroupPlaybackRate.spec.d.ts +6 -0
  262. package/bin/test/test/GroupPlaybackRate.spec.d.ts.map +1 -0
  263. package/bin/test/test/GroupPlaybackRate.spec.js +47 -0
  264. package/bin/test/test/GroupPlaybackRate.spec.js.map +1 -0
  265. package/bin/test/test/GroupPlaybackTrack.spec.d.ts +6 -0
  266. package/bin/test/test/GroupPlaybackTrack.spec.d.ts.map +1 -0
  267. package/bin/test/test/GroupPlaybackTrack.spec.js +171 -0
  268. package/bin/test/test/GroupPlaybackTrack.spec.js.map +1 -0
  269. package/bin/test/test/GroupPlaybackTrackData.spec.d.ts +6 -0
  270. package/bin/test/test/GroupPlaybackTrackData.spec.d.ts.map +1 -0
  271. package/bin/test/test/GroupPlaybackTrackData.spec.js +63 -0
  272. package/bin/test/test/GroupPlaybackTrackData.spec.js.map +1 -0
  273. package/bin/test/test/LiveMediaSession_ManualActionHandler.spec.d.ts +6 -0
  274. package/bin/test/test/LiveMediaSession_ManualActionHandler.spec.d.ts.map +1 -0
  275. package/bin/test/test/LiveMediaSession_ManualActionHandler.spec.js +323 -0
  276. package/bin/test/test/LiveMediaSession_ManualActionHandler.spec.js.map +1 -0
  277. package/bin/test/test/LiveMediaSession_Synchronizer.spec.d.ts +6 -0
  278. package/bin/test/test/LiveMediaSession_Synchronizer.spec.d.ts.map +1 -0
  279. package/bin/test/test/LiveMediaSession_Synchronizer.spec.js +669 -0
  280. package/bin/test/test/LiveMediaSession_Synchronizer.spec.js.map +1 -0
  281. package/bin/test/test/PriorityTimeInterval.spec.d.ts +6 -0
  282. package/bin/test/test/PriorityTimeInterval.spec.d.ts.map +1 -0
  283. package/bin/test/test/PriorityTimeInterval.spec.js +67 -0
  284. package/bin/test/test/PriorityTimeInterval.spec.js.map +1 -0
  285. package/bin/test/test/TestUtils.d.ts +44 -0
  286. package/bin/test/test/TestUtils.d.ts.map +1 -0
  287. package/bin/test/test/TestUtils.js +116 -0
  288. package/bin/test/test/TestUtils.js.map +1 -0
  289. package/bin/test/test/VolumeManager.spec.d.ts +2 -0
  290. package/bin/test/test/VolumeManager.spec.d.ts.map +1 -0
  291. package/bin/test/test/VolumeManager.spec.js +163 -0
  292. package/bin/test/test/VolumeManager.spec.js.map +1 -0
  293. package/package.json +3 -3
@@ -0,0 +1,97 @@
1
+ /**
2
+ * Copyright (c) Microsoft Corporation. All rights reserved.
3
+ * Licensed under the Microsoft Live Share SDK License.
4
+ */
5
+ import { DataObjectFactory } from "@fluidframework/aqueduct/legacy";
6
+ import { LiveTelemetryLogger, UserMeetingRole } from "@microsoft/live-share";
7
+ import { LiveDataObject } from "@microsoft/live-share/internal";
8
+ import { MediaPlayerSynchronizer } from "./MediaPlayerSynchronizer.js";
9
+ import { ExtendedMediaSessionAction, ExtendedMediaSessionActionHandler } from "./MediaSessionExtensions.js";
10
+ import { LiveMediaSessionCoordinator, IMediaPlayerState } from "./LiveMediaSessionCoordinator.js";
11
+ import { MediaSessionActionThrottler } from "./MediaSessionActionThrottler.js";
12
+ import { IMediaPlayer } from "./IMediaPlayer.js";
13
+ import { SharedObjectKind } from "fluid-framework";
14
+ /**
15
+ * Live fluid object that synchronizes media playback across multiple clients.
16
+ */
17
+ export declare class LiveMediaSessionClass extends LiveDataObject {
18
+ private _actionThrottler;
19
+ private _logger?;
20
+ private _requestPlayerStateHandler?;
21
+ private _coordinator?;
22
+ private readonly _actionHandlers;
23
+ private _synchronizing?;
24
+ private _updateTimer;
25
+ private _lastUpdateTime;
26
+ /**
27
+ * The objects fluid type name.
28
+ */
29
+ static readonly TypeName = "@microsoft/fluid-media:SharedMediaSession";
30
+ /**
31
+ * The objects fluid type factory.
32
+ */
33
+ static readonly factory: DataObjectFactory<LiveMediaSessionClass, import("@fluidframework/aqueduct/legacy").DataObjectTypes>;
34
+ /**
35
+ * Extension point that lets applications replace the default logic for throttling the sessions
36
+ * local sync behavior.
37
+ *
38
+ * @remarks
39
+ * The `LiveMediaCoordinator` 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(): MediaSessionActionThrottler;
48
+ set actionThrottler(value: MediaSessionActionThrottler);
49
+ /**
50
+ * The group coordinator for the session.
51
+ */
52
+ get coordinator(): LiveMediaSessionCoordinator;
53
+ /**
54
+ * Returns the logger used by the session and coordinator.
55
+ *
56
+ * @remarks
57
+ * This is used by the `MediaPlayerSynchronizer` to log events.
58
+ */
59
+ get logger(): LiveTelemetryLogger;
60
+ /**
61
+ * Initialize the object to begin sending/receiving group playback updates through this DDS.
62
+ *
63
+ * @param allowedRoles Optional. List of roles allowed to group transport operations like play/pause/seek/setTrack.
64
+ *
65
+ * @returns a void promise that resolves once complete.
66
+ *
67
+ * @throws error when `.initialize()` has already been called for this class instance.
68
+ */
69
+ initialize(allowedRoles?: UserMeetingRole[]): Promise<void>;
70
+ /**
71
+ * Registers an action handler with the session.
72
+ * @param action Name of the action to register a handler for.
73
+ * @param handler Function called when the action is triggered.
74
+ */
75
+ setActionHandler(action: ExtendedMediaSessionAction, handler: ExtendedMediaSessionActionHandler | MediaSessionActionHandler | null): void;
76
+ /**
77
+ * Registers a handler that will be queried anytime the group coordinate needs to know the
78
+ * local players transport state and position.
79
+ */
80
+ setRequestPlayerStateHandler(handler: () => IMediaPlayerState): void;
81
+ /**
82
+ * Begins synchronizing the playback of a media element.
83
+ * @param player Something that "looks like" and HTML Media Element.
84
+ * @returns A new synchronizer instance. Call `synchronizer.end()` to stop synchronizing the elements playback.
85
+ */
86
+ synchronize(player: IMediaPlayer): MediaPlayerSynchronizer;
87
+ protected hasInitialized(): Promise<void>;
88
+ private checkWaitPointHit;
89
+ private getCurrentPlayerState;
90
+ private dispatchAction;
91
+ }
92
+ /**
93
+ * Live fluid object that synchronizes media playback across multiple clients.
94
+ */
95
+ export type LiveMediaSession = LiveMediaSessionClass;
96
+ export declare const LiveMediaSession: typeof LiveMediaSessionClass & SharedObjectKind<LiveMediaSessionClass>;
97
+ //# sourceMappingURL=LiveMediaSession.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LiveMediaSession.d.ts","sourceRoot":"","sources":["../../src/LiveMediaSession.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AACpE,OAAO,EAGH,mBAAmB,EACnB,eAAe,EAClB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAEH,cAAc,EACjB,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AAEvE,OAAO,EAEH,0BAA0B,EAE1B,iCAAiC,EACpC,MAAM,6BAA6B,CAAC;AACrC,OAAO,EACH,2BAA2B,EAC3B,iBAAiB,EACpB,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EAAE,2BAA2B,EAAE,MAAM,kCAAkC,CAAC;AAE/E,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAGnD;;GAEG;AACH,qBAAa,qBAAsB,SAAQ,cAAc;IACrD,OAAO,CAAC,gBAAgB,CACU;IAClC,OAAO,CAAC,OAAO,CAAC,CAAsB;IACtC,OAAO,CAAC,0BAA0B,CAAC,CAA0B;IAC7D,OAAO,CAAC,YAAY,CAAC,CAA8B;IACnD,OAAO,CAAC,QAAQ,CAAC,eAAe,CAGlB;IACd,OAAO,CAAC,cAAc,CAAC,CAA0B;IAGjD,OAAO,CAAC,YAAY,CAAM;IAC1B,OAAO,CAAC,eAAe,CAAa;IAEpC;;OAEG;IACH,gBAAuB,QAAQ,+CAA+C;IAE9E;;OAEG;IACH,gBAAuB,OAAO,sGAK5B;IAEF;;;;;;;;;;;;OAYG;IACH,IAAW,eAAe,IAAI,2BAA2B,CAExD;IAED,IAAW,eAAe,CAAC,KAAK,EAAE,2BAA2B,EAE5D;IAED;;OAEG;IACH,IAAW,WAAW,IAAI,2BAA2B,CAEpD;IAED;;;;;OAKG;IACH,IAAW,MAAM,IAAI,mBAAmB,CAEvC;IAED;;;;;;;;OAQG;IACU,UAAU,CAAC,YAAY,CAAC,EAAE,eAAe,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAqBxE;;;;OAIG;IACI,gBAAgB,CACnB,MAAM,EAAE,0BAA0B,EAClC,OAAO,EACD,iCAAiC,GACjC,yBAAyB,GACzB,IAAI,GACX,IAAI;IAUP;;;OAGG;IACI,4BAA4B,CAAC,OAAO,EAAE,MAAM,iBAAiB;IAIpE;;;;OAIG;IACI,WAAW,CAAC,MAAM,EAAE,YAAY,GAAG,uBAAuB;cAoCjD,cAAc,IAAI,OAAO,CAAC,IAAI,CAAC;IAwF/C,OAAO,CAAC,iBAAiB;IAgCzB,OAAO,CAAC,qBAAqB;IAU7B,OAAO,CAAC,cAAc;CAQzB;AAED;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG,qBAAqB,CAAC;AAGrD,eAAO,MAAM,gBAAgB,wEAGzB,CAAC"}
@@ -0,0 +1,257 @@
1
+ /**
2
+ * Copyright (c) Microsoft Corporation. All rights reserved.
3
+ * Licensed under the Microsoft Live Share SDK License.
4
+ */
5
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
6
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
7
+ return new (P || (P = Promise))(function (resolve, reject) {
8
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
9
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
10
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
11
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
12
+ });
13
+ };
14
+ import { DataObjectFactory } from "@fluidframework/aqueduct/legacy";
15
+ import { LiveDataObjectInitializeNotNeededError, LiveDataObjectInitializeState, LiveTelemetryLogger, } from "@microsoft/live-share";
16
+ import { DynamicObjectRegistry, LiveDataObject, } from "@microsoft/live-share/internal";
17
+ import { MediaPlayerSynchronizer } from "./MediaPlayerSynchronizer.js";
18
+ import { MediaSessionCoordinatorEvents, } from "./MediaSessionExtensions.js";
19
+ import { LiveMediaSessionCoordinator, } from "./LiveMediaSessionCoordinator.js";
20
+ import { RepeatedActionThrottler } from "./RepeatedActionThrottler.js";
21
+ import { TelemetryEvents } from "./internals/consts.js";
22
+ /**
23
+ * Live fluid object that synchronizes media playback across multiple clients.
24
+ */
25
+ export class LiveMediaSessionClass extends LiveDataObject {
26
+ constructor() {
27
+ super(...arguments);
28
+ this._actionThrottler = new RepeatedActionThrottler();
29
+ this._actionHandlers = new Map();
30
+ this._lastUpdateTime = 0;
31
+ }
32
+ /**
33
+ * Extension point that lets applications replace the default logic for throttling the sessions
34
+ * local sync behavior.
35
+ *
36
+ * @remarks
37
+ * The `LiveMediaCoordinator` 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() {
46
+ return this._actionThrottler;
47
+ }
48
+ set actionThrottler(value) {
49
+ this._actionThrottler = value;
50
+ }
51
+ /**
52
+ * The group coordinator for the session.
53
+ */
54
+ get coordinator() {
55
+ return this._coordinator;
56
+ }
57
+ /**
58
+ * Returns the logger used by the session and coordinator.
59
+ *
60
+ * @remarks
61
+ * This is used by the `MediaPlayerSynchronizer` to log events.
62
+ */
63
+ get logger() {
64
+ return this._logger;
65
+ }
66
+ /**
67
+ * Initialize the object to begin sending/receiving group playback updates through this DDS.
68
+ *
69
+ * @param allowedRoles Optional. List of roles allowed to group transport operations like play/pause/seek/setTrack.
70
+ *
71
+ * @returns a void promise that resolves once complete.
72
+ *
73
+ * @throws error when `.initialize()` has already been called for this class instance.
74
+ */
75
+ initialize(allowedRoles) {
76
+ return __awaiter(this, void 0, void 0, function* () {
77
+ LiveDataObjectInitializeNotNeededError.assert("LiveMediaSession:initialize", this.initializeState);
78
+ // Update initialize state as pending
79
+ this.initializeState = LiveDataObjectInitializeState.pending;
80
+ if (allowedRoles) {
81
+ this._allowedRoles = allowedRoles;
82
+ }
83
+ try {
84
+ yield this.coordinator.initialize(allowedRoles);
85
+ }
86
+ catch (error) {
87
+ this.initializeState = LiveDataObjectInitializeState.needed;
88
+ throw error;
89
+ }
90
+ // Update initialize state as succeeded
91
+ this.initializeState = LiveDataObjectInitializeState.succeeded;
92
+ });
93
+ }
94
+ /**
95
+ * Registers an action handler with the session.
96
+ * @param action Name of the action to register a handler for.
97
+ * @param handler Function called when the action is triggered.
98
+ */
99
+ setActionHandler(action, handler) {
100
+ if (handler) {
101
+ // add handler
102
+ this._actionHandlers.set(action, handler);
103
+ }
104
+ else if (this._actionHandlers.has(action)) {
105
+ // remove handler
106
+ this._actionHandlers.delete(action);
107
+ }
108
+ }
109
+ /**
110
+ * Registers a handler that will be queried anytime the group coordinate needs to know the
111
+ * local players transport state and position.
112
+ */
113
+ setRequestPlayerStateHandler(handler) {
114
+ this._requestPlayerStateHandler = handler;
115
+ }
116
+ /**
117
+ * Begins synchronizing the playback of a media element.
118
+ * @param player Something that "looks like" and HTML Media Element.
119
+ * @returns A new synchronizer instance. Call `synchronizer.end()` to stop synchronizing the elements playback.
120
+ */
121
+ synchronize(player) {
122
+ // A session can only synchronize one player at a time
123
+ if (this._synchronizing) {
124
+ this._synchronizing.end();
125
+ }
126
+ // Start position update timer
127
+ if (!this._updateTimer) {
128
+ this.logger.sendTelemetryEvent(TelemetryEvents.MediaSession.BeginPositionUpdateTimer);
129
+ this._updateTimer = setInterval(() => {
130
+ // Get current state
131
+ const state = this.getCurrentPlayerState();
132
+ // Check for hit wait point
133
+ this.checkWaitPointHit(state);
134
+ // Send position update if interval hit
135
+ const now = new Date().getTime();
136
+ const delta = (now - this._lastUpdateTime) / 1000;
137
+ if (this.coordinator.isInitialized &&
138
+ delta >= this.coordinator.positionUpdateInterval) {
139
+ this._lastUpdateTime = now;
140
+ this.coordinator.sendPositionUpdate(state);
141
+ }
142
+ }, 500);
143
+ }
144
+ return new MediaPlayerSynchronizer(player, this, this.runtime, () => {
145
+ this._synchronizing = undefined;
146
+ });
147
+ }
148
+ hasInitialized() {
149
+ return __awaiter(this, void 0, void 0, function* () {
150
+ this._logger = new LiveTelemetryLogger(this.runtime, this.liveRuntime);
151
+ // Create coordinator and listen for triggered actions
152
+ this._coordinator = new LiveMediaSessionCoordinator(this.id, this.runtime, this.liveRuntime, () => this.getCurrentPlayerState());
153
+ this._coordinator.on(MediaSessionCoordinatorEvents.triggeraction, (event) => {
154
+ // Pre-process actions
155
+ const details = event.details;
156
+ const seekTime = typeof details.seekTime == "number" ? details.seekTime : -1;
157
+ switch (details.action) {
158
+ case "play":
159
+ this.logger.sendTelemetryEvent(TelemetryEvents.MediaSession.PlayAction, null, {
160
+ position: seekTime,
161
+ });
162
+ break;
163
+ case "pause":
164
+ this.logger.sendTelemetryEvent(TelemetryEvents.MediaSession.PauseAction, null, {
165
+ position: seekTime,
166
+ });
167
+ break;
168
+ case "ratechange":
169
+ if (!details.playbackRate) {
170
+ break;
171
+ }
172
+ this.logger.sendTelemetryEvent(TelemetryEvents.MediaSession.RateChangeAction, null, {
173
+ playbackRate: details.playbackRate,
174
+ });
175
+ break;
176
+ case "seekto":
177
+ this.logger.sendTelemetryEvent(TelemetryEvents.MediaSession.SeekToAction, null, {
178
+ position: seekTime,
179
+ });
180
+ break;
181
+ case "settrack":
182
+ this.logger.sendTelemetryEvent(TelemetryEvents.MediaSession.SetTrackAction);
183
+ break;
184
+ case "datachange":
185
+ this.logger.sendTelemetryEvent(TelemetryEvents.MediaSession.DataChangeAction);
186
+ break;
187
+ case "catchup":
188
+ // Default to seekto if catchup not implemented
189
+ this.logger.sendTelemetryEvent(TelemetryEvents.MediaSession.CatchUpAction, null, {
190
+ position: seekTime,
191
+ });
192
+ if (!this._actionHandlers.has("catchup")) {
193
+ details.action = "seekto";
194
+ }
195
+ break;
196
+ }
197
+ // Dispatch action
198
+ this.dispatchAction(details);
199
+ });
200
+ });
201
+ }
202
+ checkWaitPointHit(state) {
203
+ // Was a wait point hit?
204
+ if (state.positionState && this.coordinator.isInitialized) {
205
+ const waitPoint = this.coordinator.findNextWaitPoint();
206
+ if (waitPoint &&
207
+ state.positionState.position != undefined &&
208
+ state.positionState.position >= waitPoint.position) {
209
+ // Ensure handler registered
210
+ if (!this._actionHandlers.has("wait")) {
211
+ throw new Error(`LiveMediaSession:checkWaitPointHit - wait point hit but no 'wait' action registered.\nTo fix this error, set a \`wait\` action using the \`setActionHandler()\` function.`);
212
+ }
213
+ // Begin suspension for wait point
214
+ this.waitUntilConnected().then((clientId) => {
215
+ const suspension = this.coordinator.beginSuspension(waitPoint);
216
+ this.dispatchAction({
217
+ action: "wait",
218
+ source: "system",
219
+ clientId,
220
+ local: true,
221
+ suspension,
222
+ });
223
+ });
224
+ }
225
+ }
226
+ }
227
+ getCurrentPlayerState() {
228
+ if (!this._requestPlayerStateHandler) {
229
+ throw new Error("LiveMediaSession:getCurrentPlayerState - no `requestPlayerStateHandler` callback configured.\nTo fix this error, ensure `setRequestPlayerStateHandler()` has been set with a delegate to retrieve your player's state, or use the `synchronize()` function to create a new `MediaPlayerSynchronizer` instance tied to your `IMediaPlayer` instance.");
230
+ }
231
+ return this._requestPlayerStateHandler();
232
+ }
233
+ dispatchAction(details) {
234
+ if (this._actionHandlers.has(details.action)) {
235
+ const handler = this._actionHandlers.get(details.action);
236
+ this._actionThrottler.throttled(details, handler);
237
+ }
238
+ }
239
+ }
240
+ /**
241
+ * The objects fluid type name.
242
+ */
243
+ LiveMediaSessionClass.TypeName = `@microsoft/fluid-media:SharedMediaSession`;
244
+ /**
245
+ * The objects fluid type factory.
246
+ */
247
+ LiveMediaSessionClass.factory = new DataObjectFactory(LiveMediaSessionClass.TypeName, LiveMediaSessionClass, [], {});
248
+ // eslint-disable-next-line no-redeclare
249
+ export const LiveMediaSession = (() => {
250
+ const kind = LiveMediaSessionClass;
251
+ return kind;
252
+ })();
253
+ /**
254
+ * Register `LiveMediaSession` as an available `SharedObjectKind` for use in dynamic object loading.
255
+ */
256
+ DynamicObjectRegistry.registerObjectClass(LiveMediaSession, LiveMediaSession.TypeName);
257
+ //# sourceMappingURL=LiveMediaSession.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LiveMediaSession.js","sourceRoot":"","sources":["../../src/LiveMediaSession.ts"],"names":[],"mappings":"AAAA;;;GAGG;;;;;;;;;;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AACpE,OAAO,EACH,sCAAsC,EACtC,6BAA6B,EAC7B,mBAAmB,GAEtB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACH,qBAAqB,EACrB,cAAc,GACjB,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AAEvE,OAAO,EACH,6BAA6B,GAIhC,MAAM,6BAA6B,CAAC;AACrC,OAAO,EACH,2BAA2B,GAE9B,MAAM,kCAAkC,CAAC;AAE1C,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C,gBAAgB,CAAC,SAAS,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QACtD,CAAC;IACL,CAAC;;AAlSD;;GAEG;AACoB,8BAAQ,GAAG,2CAA2C,AAA9C,CAA+C;AAE9E;;GAEG;AACoB,6BAAO,GAAG,IAAI,iBAAiB,CAClD,qBAAqB,CAAC,QAAQ,EAC9B,qBAAqB,EACrB,EAAE,EACF,EAAE,CACL,AAL6B,CAK5B;AA6RN,wCAAwC;AACxC,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,GAAG,EAAE;IAClC,MAAM,IAAI,GAAG,qBAAqB,CAAC;IACnC,OAAO,IAA6D,CAAC;AACzE,CAAC,CAAC,EAAE,CAAC;AAEL;;GAEG;AACH,qBAAqB,CAAC,mBAAmB,CACrC,gBAAgB,EAChB,gBAAgB,CAAC,QAAQ,CAC5B,CAAC"}
@@ -0,0 +1,304 @@
1
+ /**
2
+ * Copyright (c) Microsoft Corporation. All rights reserved.
3
+ * Licensed under the Microsoft Live Share SDK License.
4
+ */
5
+ import { UserMeetingRole } from "@microsoft/live-share";
6
+ import { IRuntimeSignaler, LiveShareRuntime } from "@microsoft/live-share/internal";
7
+ import { CoordinationWaitPoint, ExtendedMediaMetadata, ExtendedMediaSessionPlaybackState, MediaSessionCoordinatorSuspension } from "./MediaSessionExtensions.js";
8
+ import { TypedEventEmitter } from "@fluid-internal/client-utils";
9
+ import { IEvent } from "@fluidframework/core-interfaces";
10
+ /**
11
+ * Most recent state of the media session.
12
+ */
13
+ export interface IMediaPlayerState {
14
+ /**
15
+ * Metadata for the sessions current track.
16
+ */
17
+ metadata: ExtendedMediaMetadata | null;
18
+ /**
19
+ * Optional track data object being synchronized.
20
+ *
21
+ * @remarks
22
+ * This can be used to sync things like pitch, roll, and yaw when watching 360 videos together.
23
+ */
24
+ trackData: object | null;
25
+ /**
26
+ * Sessions current playback state.
27
+ */
28
+ playbackState: ExtendedMediaSessionPlaybackState;
29
+ /**
30
+ * Sessions current position state if known.
31
+ */
32
+ positionState?: MediaPositionState;
33
+ }
34
+ /**
35
+ * @hidden
36
+ */
37
+ export interface ILiveMediaSessionCoordinatorEvents extends IEvent {
38
+ /**
39
+ * Event listener for events emitted
40
+ * @param event update
41
+ * @param listener listener function
42
+ * @param listener.event the event instance
43
+ */
44
+ (event: string, listener: (event: any) => void): void;
45
+ }
46
+ /**
47
+ * The `LiveMediaSessionCoordinator` tracks the playback & position state of all other
48
+ * clients being synchronized with. It is responsible for keeping the local media player
49
+ * in sync with the group.
50
+ */
51
+ export declare class LiveMediaSessionCoordinator extends TypedEventEmitter<ILiveMediaSessionCoordinatorEvents> {
52
+ private readonly _id;
53
+ private readonly _runtime;
54
+ private readonly _liveRuntime;
55
+ private readonly _logger;
56
+ private readonly _getPlayerState;
57
+ private _positionUpdateInterval;
58
+ private _maxPlaybackDrift;
59
+ private _lastWaitPoint?;
60
+ private initializeState;
61
+ private _playEvent?;
62
+ private _pauseEvent?;
63
+ private _seekToEvent?;
64
+ private _rateChangeEvent?;
65
+ private _setTrackEvent?;
66
+ private _setTrackDataEvent?;
67
+ private _positionUpdateEvent?;
68
+ private _synchronizer?;
69
+ private _groupState?;
70
+ /**
71
+ * @hidden
72
+ * Applications shouldn't directly create new coordinator instances.
73
+ */
74
+ constructor(id: string, runtime: IRuntimeSignaler, liveRuntime: LiveShareRuntime, getPlayerState: () => IMediaPlayerState);
75
+ /**
76
+ * Controls whether or not the local client is allowed to instruct the group to play or pause.
77
+ *
78
+ * @remarks
79
+ * This flag largely meant to influence decisions made by the coordinator and can be used by
80
+ * the UI to determine what controls should be shown to the user. It does not provide any
81
+ * security in itself.
82
+ *
83
+ * If your app is running in a semi-trusted environment where only some clients are allowed
84
+ * to play/pause media, you should use "role based verification" to enforce those policies.
85
+ */
86
+ canPlayPause: boolean;
87
+ /**
88
+ * Controls whether or not the local client is allowed to seek the group to a new playback
89
+ * position.
90
+ *
91
+ * @remarks
92
+ * This flag largely meant to influence decisions made by the coordinator and can be used by
93
+ * the UI to determine what controls should be shown to the user. It does not provide any
94
+ * security in itself.
95
+ *
96
+ * If your app is running in a semi-trusted environment where only some clients are allowed
97
+ * to change the playback position, you should use "role based verification" to enforce those policies.
98
+ */
99
+ canSeek: boolean;
100
+ /**
101
+ * Controls whether or not the local client is allowed to change tracks.
102
+ *
103
+ * @remarks
104
+ * This flag largely meant to influence decisions made by the coordinator and can be used by
105
+ * the UI to determine what controls should be shown to the user. It does not provide any
106
+ * security in itself.
107
+ *
108
+ * If your app is running in a semi-trusted environment where only some clients are allowed
109
+ * to change tracks, you should use "role based verification" to enforce those policies.
110
+ */
111
+ canSetTrack: boolean;
112
+ /**
113
+ * Controls whether or not the local client is allowed to change the tracks custom data object.
114
+ *
115
+ * @remarks
116
+ * This flag largely meant to influence decisions made by the coordinator and can be used by
117
+ * the UI to determine what controls should be shown to the user. It does not provide any
118
+ * security in itself.
119
+ *
120
+ * If your app is running in a semi-trusted environment where only some clients are allowed
121
+ * to change the tracks data object, you should use "role based verification" to enforce those
122
+ * policies.
123
+ */
124
+ canSetTrackData: boolean;
125
+ /**
126
+ * Controls whether or not the local client is allowed to change the playback rate.
127
+ *
128
+ * @remarks
129
+ * This flag largely meant to influence decisions made by the coordinator and can be used by
130
+ * the UI to determine what controls should be shown to the user. It does not provide any
131
+ * security in itself.
132
+ *
133
+ * If your app is running in a semi-trusted environment where only some clients are allowed
134
+ * to change the tracks data object, you should use "role based verification" to enforce those
135
+ * policies.
136
+ */
137
+ canSetPlaybackRate: boolean;
138
+ /**
139
+ * Controls whether or not the local client is allowed to send position updates to the group.
140
+ *
141
+ * @remarks
142
+ * This flag largely meant to limit the number of signals sent to the group for performance reasons.
143
+ * It does not provide any security in itself.
144
+ */
145
+ canSendPositionUpdates: boolean;
146
+ /**
147
+ * Returns true if the local client is in a suspended state.
148
+ */
149
+ get isSuspended(): boolean;
150
+ /**
151
+ * Controls whether or not to scale {@link maxPlaybackDrift} by the number of users in the session.
152
+ *
153
+ * @remarks
154
+ * As more clients join a session, it is more likely that some users will fall behind the presenter.
155
+ * It is also less likely that users will notice drift as more clients are added.
156
+ * It is usually helpful to be more lenient as more clients are added so everyone can watch all the content.
157
+ * Default value is true.
158
+ */
159
+ get shouldScaleMaxPlaybackDrift(): boolean;
160
+ set shouldScaleMaxPlaybackDrift(value: boolean);
161
+ /**
162
+ * Max amount of playback drift allowed in seconds.
163
+ * This will scale automatically according to the number of participants in the session when {@link shouldScaleMaxPlaybackDrift} is true.
164
+ *
165
+ * @remarks
166
+ * Should the local clients playback position lag by more than the specified value, the coordinator will trigger a `catchup` action.
167
+ * Default value is `1.5` seconds.
168
+ */
169
+ get maxPlaybackDrift(): number;
170
+ set maxPlaybackDrift(value: number);
171
+ /**
172
+ * Controls whether or not to compute {@link positionUpdateInterval} based on whether user has initiated a playback command.
173
+ * Default value is true.
174
+ *
175
+ * @remarks
176
+ * When true, users that are simply watching but not controlling playback will report their positions less frequently.
177
+ * When a user has sent a transport command, they will begin sending position updates more frequently.
178
+ * Most Live Share apps have a concept of a primary presenter, and don't allow anyone to pause/play for the group.
179
+ * By ensuring only one/few users broadcast updates frequently, the server load is reduced considerably.
180
+ */
181
+ get shouldScalePositionUpdateInterval(): boolean;
182
+ set shouldScalePositionUpdateInterval(value: boolean);
183
+ /**
184
+ * Frequency with which position updates are broadcast to the rest of the group in seconds.
185
+ * When {@link shouldScalePositionUpdateInterval} is set to `true`, the value set is the minimum value.
186
+ * The value returned is the actual value used to send updates by the local user, which may be larger than the value set.
187
+ *
188
+ * @remarks
189
+ * Defaults to a minimum value of `2` seconds.
190
+ */
191
+ get positionUpdateInterval(): number;
192
+ set positionUpdateInterval(value: number);
193
+ /**
194
+ * Instructs the group to play the current track.
195
+ *
196
+ * @remarks
197
+ * Throws an exception if the session/coordinator hasn't been initialized, no track has been
198
+ * loaded, or `canPlayPause` is false.
199
+ *
200
+ * @returns a void promise that resolves once complete, throws if user does not have proper roles
201
+ */
202
+ play(): Promise<void>;
203
+ /**
204
+ * Instructs the group to pause the current track.
205
+ *
206
+ * @remarks
207
+ * Throws an exception if the session/coordinator hasn't been initialized, no track has been
208
+ * loaded, or `canPlayPause` is false.
209
+ *
210
+ * @returns a void promise that resolves once complete, throws if user does not have proper roles
211
+ */
212
+ pause(): Promise<void>;
213
+ /**
214
+ * Instructs the group to seek to a new position within the current track.
215
+ *
216
+ * @remarks
217
+ * Throws an exception if the session/coordinator hasn't been initialized, no track has been
218
+ * loaded, or `canSeek` is false.
219
+ * @param time Playback position in seconds to seek to.
220
+ * @returns a void promise that resolves once complete, throws if user does not have proper roles
221
+ */
222
+ seekTo(time: number): Promise<void>;
223
+ /**
224
+ * Sets the playback rate for everyone in the session.
225
+ *
226
+ * @param playbackRate the playback rate to set.
227
+ *
228
+ * @throws
229
+ * Throws an exception if the session/coordinator hasn't been initialized or {@link canSetPlaybackRate} is false.
230
+ */
231
+ setPlaybackRate(playbackRate: number): Promise<void>;
232
+ /**
233
+ * Instructs the group to load a new track.
234
+ *
235
+ * @remarks
236
+ * Throws an exception if the session/coordinator hasn't been initialized or `canSetTrack` is
237
+ * false.
238
+ * @param metadata The track to load or `null` to indicate that the end of the track is reached.
239
+ * @param waitPoints Optional. List of static wait points to configure for the track. Dynamic wait points can be added via the `beginSuspension()` call.
240
+ * @returns a void promise that resolves once complete, throws if user does not have proper roles
241
+ */
242
+ setTrack(metadata: ExtendedMediaMetadata | null, waitPoints?: CoordinationWaitPoint[]): Promise<void>;
243
+ /**
244
+ * Updates the track data object for the current track.
245
+ *
246
+ * @remarks
247
+ * The track data object can be used by applications to synchronize things like pitch, roll,
248
+ * and yaw of a 360 video. This data object will be reset to null anytime the track changes.
249
+ *
250
+ * Throws an exception if the session/coordinator hasn't been initialized or `canSetTrackData` is
251
+ * false.
252
+ * @param data New data object to sync with the group. This value will be synchronized using a last writer wins strategy.
253
+ * @returns a void promise that resolves once complete, throws if user does not have proper roles
254
+ */
255
+ setTrackData(data: object | null): Promise<void>;
256
+ /**
257
+ * Begins a new local suspension.
258
+ *
259
+ * @remarks
260
+ * Suspension temporarily suspend the clients local synchronization with the group. This can
261
+ * be useful for displaying ads to users or temporarily disconnecting from the session while
262
+ * the user seeks the video using a timeline scrubber.
263
+ *
264
+ * Multiple simultaneous suspensions are allowed and when the last suspension ends the local
265
+ * client will be immediately re-synchronized with the group.
266
+ *
267
+ * A "Dynamic Wait Point" can be specified when `beginSuspension()` is called and the wait
268
+ * point will be broadcast to all other clients in the group. Those clients will then
269
+ * automatically enter a suspension state once they reach the positions specified by the
270
+ * wait point. Clients that are passed the wait point will immediately suspend.
271
+ *
272
+ * Any wait point based suspension (dynamic or static) will result in all clients remaining
273
+ * in a suspension state until the list client ends their suspension. This behavior can be
274
+ * conditionally bypassed by settings the wait points `maxClients` value.
275
+ *
276
+ * Throws an exception if the session/coordinator hasn't been initialized.
277
+ * @param waitPoint Optional. Dynamic wait point to broadcast to all of the clients.
278
+ * @returns The suspension object. Call `end()` on the returned suspension to end the suspension.
279
+ */
280
+ beginSuspension(waitPoint?: CoordinationWaitPoint): MediaSessionCoordinatorSuspension;
281
+ /**
282
+ * @hidden
283
+ * Called by MediaSession to verify the coordinator has been initialized.
284
+ */
285
+ get isInitialized(): boolean;
286
+ /**
287
+ * @hidden
288
+ * Called by MediaSession to start coordinator.
289
+ */
290
+ initialize(acceptTransportChangesFrom?: UserMeetingRole[]): Promise<void>;
291
+ /**
292
+ * @hidden
293
+ * Called by the MediaSession to detect if a wait point has been hit.
294
+ */
295
+ findNextWaitPoint(): CoordinationWaitPoint | null;
296
+ /**
297
+ * @hidden
298
+ * Called by MediaSession to trigger the sending of a position update.
299
+ */
300
+ sendPositionUpdate(state: IMediaPlayerState, targetClientId?: string): void;
301
+ protected createChildren(acceptTransportChangesFrom?: UserMeetingRole[]): Promise<void>;
302
+ private getPlayerPosition;
303
+ }
304
+ //# sourceMappingURL=LiveMediaSessionCoordinator.d.ts.map