Group.cs 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Threading;
  5. using System.Threading.Tasks;
  6. using Jellyfin.Data.Entities;
  7. using MediaBrowser.Controller.Library;
  8. using MediaBrowser.Controller.Session;
  9. using MediaBrowser.Controller.SyncPlay;
  10. using MediaBrowser.Controller.SyncPlay.GroupStates;
  11. using MediaBrowser.Controller.SyncPlay.Queue;
  12. using MediaBrowser.Controller.SyncPlay.Requests;
  13. using MediaBrowser.Model.SyncPlay;
  14. using Microsoft.Extensions.Logging;
  15. namespace Emby.Server.Implementations.SyncPlay
  16. {
  17. /// <summary>
  18. /// Class Group.
  19. /// </summary>
  20. /// <remarks>
  21. /// Class is not thread-safe, external locking is required when accessing methods.
  22. /// </remarks>
  23. public class Group : IGroupStateContext
  24. {
  25. /// <summary>
  26. /// The logger.
  27. /// </summary>
  28. private readonly ILogger<Group> _logger;
  29. /// <summary>
  30. /// The logger factory.
  31. /// </summary>
  32. private readonly ILoggerFactory _loggerFactory;
  33. /// <summary>
  34. /// The user manager.
  35. /// </summary>
  36. private readonly IUserManager _userManager;
  37. /// <summary>
  38. /// The session manager.
  39. /// </summary>
  40. private readonly ISessionManager _sessionManager;
  41. /// <summary>
  42. /// The library manager.
  43. /// </summary>
  44. private readonly ILibraryManager _libraryManager;
  45. /// <summary>
  46. /// The participants, or members of the group.
  47. /// </summary>
  48. private readonly Dictionary<string, GroupMember> _participants =
  49. new Dictionary<string, GroupMember>(StringComparer.OrdinalIgnoreCase);
  50. /// <summary>
  51. /// The internal group state.
  52. /// </summary>
  53. private IGroupState _state;
  54. /// <summary>
  55. /// Initializes a new instance of the <see cref="Group" /> class.
  56. /// </summary>
  57. /// <param name="loggerFactory">The logger factory.</param>
  58. /// <param name="userManager">The user manager.</param>
  59. /// <param name="sessionManager">The session manager.</param>
  60. /// <param name="libraryManager">The library manager.</param>
  61. public Group(
  62. ILoggerFactory loggerFactory,
  63. IUserManager userManager,
  64. ISessionManager sessionManager,
  65. ILibraryManager libraryManager)
  66. {
  67. _loggerFactory = loggerFactory;
  68. _userManager = userManager;
  69. _sessionManager = sessionManager;
  70. _libraryManager = libraryManager;
  71. _logger = loggerFactory.CreateLogger<Group>();
  72. _state = new IdleGroupState(loggerFactory);
  73. }
  74. /// <summary>
  75. /// Gets the default ping value used for sessions.
  76. /// </summary>
  77. /// <value>The default ping.</value>
  78. public long DefaultPing { get; } = 500;
  79. /// <summary>
  80. /// Gets the maximum time offset error accepted for dates reported by clients, in milliseconds.
  81. /// </summary>
  82. /// <value>The maximum time offset error.</value>
  83. public long TimeSyncOffset { get; } = 2000;
  84. /// <summary>
  85. /// Gets the maximum offset error accepted for position reported by clients, in milliseconds.
  86. /// </summary>
  87. /// <value>The maximum offset error.</value>
  88. public long MaxPlaybackOffset { get; } = 500;
  89. /// <summary>
  90. /// Gets the group identifier.
  91. /// </summary>
  92. /// <value>The group identifier.</value>
  93. public Guid GroupId { get; } = Guid.NewGuid();
  94. /// <summary>
  95. /// Gets the group name.
  96. /// </summary>
  97. /// <value>The group name.</value>
  98. public string GroupName { get; private set; }
  99. /// <summary>
  100. /// Gets the group identifier.
  101. /// </summary>
  102. /// <value>The group identifier.</value>
  103. public PlayQueueManager PlayQueue { get; } = new PlayQueueManager();
  104. /// <summary>
  105. /// Gets the runtime ticks of current playing item.
  106. /// </summary>
  107. /// <value>The runtime ticks of current playing item.</value>
  108. public long RunTimeTicks { get; private set; }
  109. /// <summary>
  110. /// Gets or sets the position ticks.
  111. /// </summary>
  112. /// <value>The position ticks.</value>
  113. public long PositionTicks { get; set; }
  114. /// <summary>
  115. /// Gets or sets the last activity.
  116. /// </summary>
  117. /// <value>The last activity.</value>
  118. public DateTime LastActivity { get; set; }
  119. /// <summary>
  120. /// Adds the session to the group.
  121. /// </summary>
  122. /// <param name="session">The session.</param>
  123. private void AddSession(SessionInfo session)
  124. {
  125. _participants.TryAdd(
  126. session.Id,
  127. new GroupMember(session)
  128. {
  129. Ping = DefaultPing,
  130. IsBuffering = false
  131. });
  132. }
  133. /// <summary>
  134. /// Removes the session from the group.
  135. /// </summary>
  136. /// <param name="session">The session.</param>
  137. private void RemoveSession(SessionInfo session)
  138. {
  139. _participants.Remove(session.Id);
  140. }
  141. /// <summary>
  142. /// Filters sessions of this group.
  143. /// </summary>
  144. /// <param name="from">The current session.</param>
  145. /// <param name="type">The filtering type.</param>
  146. /// <returns>The list of sessions matching the filter.</returns>
  147. private IEnumerable<SessionInfo> FilterSessions(SessionInfo from, SyncPlayBroadcastType type)
  148. {
  149. return type switch
  150. {
  151. SyncPlayBroadcastType.CurrentSession => new SessionInfo[] { from },
  152. SyncPlayBroadcastType.AllGroup => _participants
  153. .Values
  154. .Select(session => session.Session),
  155. SyncPlayBroadcastType.AllExceptCurrentSession => _participants
  156. .Values
  157. .Select(session => session.Session)
  158. .Where(session => !session.Id.Equals(from.Id, StringComparison.OrdinalIgnoreCase)),
  159. SyncPlayBroadcastType.AllReady => _participants
  160. .Values
  161. .Where(session => !session.IsBuffering)
  162. .Select(session => session.Session),
  163. _ => Enumerable.Empty<SessionInfo>()
  164. };
  165. }
  166. /// <summary>
  167. /// Checks if a given user can access all items of a given queue, that is,
  168. /// the user has the required minimum parental access and has access to all required folders.
  169. /// </summary>
  170. /// <param name="user">The user.</param>
  171. /// <param name="queue">The queue.</param>
  172. /// <returns><c>true</c> if the user can access all the items in the queue, <c>false</c> otherwise.</returns>
  173. private bool HasAccessToQueue(User user, IReadOnlyList<Guid> queue)
  174. {
  175. // Check if queue is empty.
  176. if (queue == null || queue.Count == 0)
  177. {
  178. return true;
  179. }
  180. foreach (var itemId in queue)
  181. {
  182. var item = _libraryManager.GetItemById(itemId);
  183. if (!item.IsVisibleStandalone(user))
  184. {
  185. return false;
  186. }
  187. }
  188. return true;
  189. }
  190. private bool AllUsersHaveAccessToQueue(IReadOnlyList<Guid> queue)
  191. {
  192. // Check if queue is empty.
  193. if (queue == null || queue.Count == 0)
  194. {
  195. return true;
  196. }
  197. // Get list of users.
  198. var users = _participants
  199. .Values
  200. .Select(participant => _userManager.GetUserById(participant.Session.UserId));
  201. // Find problematic users.
  202. var usersWithNoAccess = users.Where(user => !HasAccessToQueue(user, queue));
  203. // All users must be able to access the queue.
  204. return !usersWithNoAccess.Any();
  205. }
  206. /// <summary>
  207. /// Checks if the group is empty.
  208. /// </summary>
  209. /// <returns><c>true</c> if the group is empty, <c>false</c> otherwise.</returns>
  210. public bool IsGroupEmpty() => _participants.Count == 0;
  211. /// <summary>
  212. /// Initializes the group with the session's info.
  213. /// </summary>
  214. /// <param name="session">The session.</param>
  215. /// <param name="request">The request.</param>
  216. /// <param name="cancellationToken">The cancellation token.</param>
  217. public void CreateGroup(SessionInfo session, NewGroupRequest request, CancellationToken cancellationToken)
  218. {
  219. GroupName = request.GroupName;
  220. AddSession(session);
  221. var sessionIsPlayingAnItem = session.FullNowPlayingItem != null;
  222. RestartCurrentItem();
  223. if (sessionIsPlayingAnItem)
  224. {
  225. var playlist = session.NowPlayingQueue.Select(item => item.Id).ToList();
  226. PlayQueue.Reset();
  227. PlayQueue.SetPlaylist(playlist);
  228. PlayQueue.SetPlayingItemById(session.FullNowPlayingItem.Id);
  229. RunTimeTicks = session.FullNowPlayingItem.RunTimeTicks ?? 0;
  230. PositionTicks = session.PlayState.PositionTicks ?? 0;
  231. // Maintain playstate.
  232. var waitingState = new WaitingGroupState(_loggerFactory)
  233. {
  234. ResumePlaying = !session.PlayState.IsPaused
  235. };
  236. SetState(waitingState);
  237. }
  238. var updateSession = NewSyncPlayGroupUpdate(GroupUpdateType.GroupJoined, GetInfo());
  239. SendGroupUpdate(session, SyncPlayBroadcastType.CurrentSession, updateSession, cancellationToken);
  240. _state.SessionJoined(this, _state.Type, session, cancellationToken);
  241. _logger.LogInformation("Session {SessionId} created group {GroupId}.", session.Id, GroupId.ToString());
  242. }
  243. /// <summary>
  244. /// Adds the session to the group.
  245. /// </summary>
  246. /// <param name="session">The session.</param>
  247. /// <param name="request">The request.</param>
  248. /// <param name="cancellationToken">The cancellation token.</param>
  249. public void SessionJoin(SessionInfo session, JoinGroupRequest request, CancellationToken cancellationToken)
  250. {
  251. AddSession(session);
  252. var updateSession = NewSyncPlayGroupUpdate(GroupUpdateType.GroupJoined, GetInfo());
  253. SendGroupUpdate(session, SyncPlayBroadcastType.CurrentSession, updateSession, cancellationToken);
  254. var updateOthers = NewSyncPlayGroupUpdate(GroupUpdateType.UserJoined, session.UserName);
  255. SendGroupUpdate(session, SyncPlayBroadcastType.AllExceptCurrentSession, updateOthers, cancellationToken);
  256. _state.SessionJoined(this, _state.Type, session, cancellationToken);
  257. _logger.LogInformation("Session {SessionId} joined group {GroupId}.", session.Id, GroupId.ToString());
  258. }
  259. /// <summary>
  260. /// Removes the session from the group.
  261. /// </summary>
  262. /// <param name="session">The session.</param>
  263. /// <param name="request">The request.</param>
  264. /// <param name="cancellationToken">The cancellation token.</param>
  265. public void SessionLeave(SessionInfo session, LeaveGroupRequest request, CancellationToken cancellationToken)
  266. {
  267. _state.SessionLeaving(this, _state.Type, session, cancellationToken);
  268. RemoveSession(session);
  269. var updateSession = NewSyncPlayGroupUpdate(GroupUpdateType.GroupLeft, GroupId.ToString());
  270. SendGroupUpdate(session, SyncPlayBroadcastType.CurrentSession, updateSession, cancellationToken);
  271. var updateOthers = NewSyncPlayGroupUpdate(GroupUpdateType.UserLeft, session.UserName);
  272. SendGroupUpdate(session, SyncPlayBroadcastType.AllExceptCurrentSession, updateOthers, cancellationToken);
  273. _logger.LogInformation("Session {SessionId} left group {GroupId}.", session.Id, GroupId.ToString());
  274. }
  275. /// <summary>
  276. /// Handles the requested action by the session.
  277. /// </summary>
  278. /// <param name="session">The session.</param>
  279. /// <param name="request">The requested action.</param>
  280. /// <param name="cancellationToken">The cancellation token.</param>
  281. public void HandleRequest(SessionInfo session, IGroupPlaybackRequest request, CancellationToken cancellationToken)
  282. {
  283. // The server's job is to maintain a consistent state for clients to reference
  284. // and notify clients of state changes. The actual syncing of media playback
  285. // happens client side. Clients are aware of the server's time and use it to sync.
  286. _logger.LogInformation("Session {SessionId} requested {RequestType} in group {GroupId} that is {StateType}.", session.Id, request.Action, GroupId.ToString(), _state.Type);
  287. // Apply requested changes to this group given its current state.
  288. // Every request has a slightly different outcome depending on the group's state.
  289. // There are currently four different group states that accomplish different goals:
  290. // - Idle: in this state no media is playing and clients should be idle (playback is stopped).
  291. // - Waiting: in this state the group is waiting for all the clients to be ready to start the playback,
  292. // that is, they've either finished loading the media for the first time or they've finished buffering.
  293. // Once all clients report to be ready the group's state can change to Playing or Paused.
  294. // - Playing: clients have some media loaded and playback is unpaused.
  295. // - Paused: clients have some media loaded but playback is currently paused.
  296. request.Apply(this, _state, session, cancellationToken);
  297. }
  298. /// <summary>
  299. /// Gets the info about the group for the clients.
  300. /// </summary>
  301. /// <returns>The group info for the clients.</returns>
  302. public GroupInfoDto GetInfo()
  303. {
  304. var participants = _participants.Values.Select(session => session.Session.UserName).Distinct().ToList();
  305. return new GroupInfoDto(GroupId, GroupName, _state.Type, participants, DateTime.UtcNow);
  306. }
  307. /// <summary>
  308. /// Checks if a user has access to all content in the play queue.
  309. /// </summary>
  310. /// <param name="user">The user.</param>
  311. /// <returns><c>true</c> if the user can access the play queue; <c>false</c> otherwise.</returns>
  312. public bool HasAccessToPlayQueue(User user)
  313. {
  314. var items = PlayQueue.GetPlaylist().Select(item => item.ItemId).ToList();
  315. return HasAccessToQueue(user, items);
  316. }
  317. /// <inheritdoc />
  318. public void SetIgnoreGroupWait(SessionInfo session, bool ignoreGroupWait)
  319. {
  320. if (_participants.TryGetValue(session.Id, out GroupMember value))
  321. {
  322. value.IgnoreGroupWait = ignoreGroupWait;
  323. }
  324. }
  325. /// <inheritdoc />
  326. public void SetState(IGroupState state)
  327. {
  328. _logger.LogInformation("Group {GroupId} switching from {FromStateType} to {ToStateType}.", GroupId.ToString(), _state.Type, state.Type);
  329. this._state = state;
  330. }
  331. /// <inheritdoc />
  332. public Task SendGroupUpdate<T>(SessionInfo from, SyncPlayBroadcastType type, GroupUpdate<T> message, CancellationToken cancellationToken)
  333. {
  334. IEnumerable<Task> GetTasks()
  335. {
  336. foreach (var session in FilterSessions(from, type))
  337. {
  338. yield return _sessionManager.SendSyncPlayGroupUpdate(session, message, cancellationToken);
  339. }
  340. }
  341. return Task.WhenAll(GetTasks());
  342. }
  343. /// <inheritdoc />
  344. public Task SendCommand(SessionInfo from, SyncPlayBroadcastType type, SendCommand message, CancellationToken cancellationToken)
  345. {
  346. IEnumerable<Task> GetTasks()
  347. {
  348. foreach (var session in FilterSessions(from, type))
  349. {
  350. yield return _sessionManager.SendSyncPlayCommand(session, message, cancellationToken);
  351. }
  352. }
  353. return Task.WhenAll(GetTasks());
  354. }
  355. /// <inheritdoc />
  356. public SendCommand NewSyncPlayCommand(SendCommandType type)
  357. {
  358. return new SendCommand(
  359. GroupId,
  360. PlayQueue.GetPlayingItemPlaylistId(),
  361. LastActivity,
  362. type,
  363. PositionTicks,
  364. DateTime.UtcNow);
  365. }
  366. /// <inheritdoc />
  367. public GroupUpdate<T> NewSyncPlayGroupUpdate<T>(GroupUpdateType type, T data)
  368. {
  369. return new GroupUpdate<T>(GroupId, type, data);
  370. }
  371. /// <inheritdoc />
  372. public long SanitizePositionTicks(long? positionTicks)
  373. {
  374. var ticks = positionTicks ?? 0;
  375. return Math.Clamp(ticks, 0, RunTimeTicks);
  376. }
  377. /// <inheritdoc />
  378. public void UpdatePing(SessionInfo session, long ping)
  379. {
  380. if (_participants.TryGetValue(session.Id, out GroupMember value))
  381. {
  382. value.Ping = ping;
  383. }
  384. }
  385. /// <inheritdoc />
  386. public long GetHighestPing()
  387. {
  388. long max = long.MinValue;
  389. foreach (var session in _participants.Values)
  390. {
  391. max = Math.Max(max, session.Ping);
  392. }
  393. return max;
  394. }
  395. /// <inheritdoc />
  396. public void SetBuffering(SessionInfo session, bool isBuffering)
  397. {
  398. if (_participants.TryGetValue(session.Id, out GroupMember value))
  399. {
  400. value.IsBuffering = isBuffering;
  401. }
  402. }
  403. /// <inheritdoc />
  404. public void SetAllBuffering(bool isBuffering)
  405. {
  406. foreach (var session in _participants.Values)
  407. {
  408. session.IsBuffering = isBuffering;
  409. }
  410. }
  411. /// <inheritdoc />
  412. public bool IsBuffering()
  413. {
  414. foreach (var session in _participants.Values)
  415. {
  416. if (session.IsBuffering && !session.IgnoreGroupWait)
  417. {
  418. return true;
  419. }
  420. }
  421. return false;
  422. }
  423. /// <inheritdoc />
  424. public bool SetPlayQueue(IReadOnlyList<Guid> playQueue, int playingItemPosition, long startPositionTicks)
  425. {
  426. // Ignore on empty queue or invalid item position.
  427. if (playQueue.Count == 0 || playingItemPosition >= playQueue.Count || playingItemPosition < 0)
  428. {
  429. return false;
  430. }
  431. // Check if participants can access the new playing queue.
  432. if (!AllUsersHaveAccessToQueue(playQueue))
  433. {
  434. return false;
  435. }
  436. PlayQueue.Reset();
  437. PlayQueue.SetPlaylist(playQueue);
  438. PlayQueue.SetPlayingItemByIndex(playingItemPosition);
  439. var item = _libraryManager.GetItemById(PlayQueue.GetPlayingItemId());
  440. RunTimeTicks = item.RunTimeTicks ?? 0;
  441. PositionTicks = startPositionTicks;
  442. LastActivity = DateTime.UtcNow;
  443. return true;
  444. }
  445. /// <inheritdoc />
  446. public bool SetPlayingItem(Guid playlistItemId)
  447. {
  448. var itemFound = PlayQueue.SetPlayingItemByPlaylistId(playlistItemId);
  449. if (itemFound)
  450. {
  451. var item = _libraryManager.GetItemById(PlayQueue.GetPlayingItemId());
  452. RunTimeTicks = item.RunTimeTicks ?? 0;
  453. }
  454. else
  455. {
  456. RunTimeTicks = 0;
  457. }
  458. RestartCurrentItem();
  459. return itemFound;
  460. }
  461. /// <inheritdoc />
  462. public bool RemoveFromPlayQueue(IReadOnlyList<Guid> playlistItemIds)
  463. {
  464. var playingItemRemoved = PlayQueue.RemoveFromPlaylist(playlistItemIds);
  465. if (playingItemRemoved)
  466. {
  467. var itemId = PlayQueue.GetPlayingItemId();
  468. if (!itemId.Equals(Guid.Empty))
  469. {
  470. var item = _libraryManager.GetItemById(itemId);
  471. RunTimeTicks = item.RunTimeTicks ?? 0;
  472. }
  473. else
  474. {
  475. RunTimeTicks = 0;
  476. }
  477. RestartCurrentItem();
  478. }
  479. return playingItemRemoved;
  480. }
  481. /// <inheritdoc />
  482. public bool MoveItemInPlayQueue(Guid playlistItemId, int newIndex)
  483. {
  484. return PlayQueue.MovePlaylistItem(playlistItemId, newIndex);
  485. }
  486. /// <inheritdoc />
  487. public bool AddToPlayQueue(IReadOnlyList<Guid> newItems, GroupQueueMode mode)
  488. {
  489. // Ignore on empty list.
  490. if (newItems.Count == 0)
  491. {
  492. return false;
  493. }
  494. // Check if participants can access the new playing queue.
  495. if (!AllUsersHaveAccessToQueue(newItems))
  496. {
  497. return false;
  498. }
  499. if (mode.Equals(GroupQueueMode.QueueNext))
  500. {
  501. PlayQueue.QueueNext(newItems);
  502. }
  503. else
  504. {
  505. PlayQueue.Queue(newItems);
  506. }
  507. return true;
  508. }
  509. /// <inheritdoc />
  510. public void RestartCurrentItem()
  511. {
  512. PositionTicks = 0;
  513. LastActivity = DateTime.UtcNow;
  514. }
  515. /// <inheritdoc />
  516. public bool NextItemInQueue()
  517. {
  518. var update = PlayQueue.Next();
  519. if (update)
  520. {
  521. var item = _libraryManager.GetItemById(PlayQueue.GetPlayingItemId());
  522. RunTimeTicks = item.RunTimeTicks ?? 0;
  523. RestartCurrentItem();
  524. return true;
  525. }
  526. else
  527. {
  528. return false;
  529. }
  530. }
  531. /// <inheritdoc />
  532. public bool PreviousItemInQueue()
  533. {
  534. var update = PlayQueue.Previous();
  535. if (update)
  536. {
  537. var item = _libraryManager.GetItemById(PlayQueue.GetPlayingItemId());
  538. RunTimeTicks = item.RunTimeTicks ?? 0;
  539. RestartCurrentItem();
  540. return true;
  541. }
  542. else
  543. {
  544. return false;
  545. }
  546. }
  547. /// <inheritdoc />
  548. public void SetRepeatMode(GroupRepeatMode mode)
  549. {
  550. PlayQueue.SetRepeatMode(mode);
  551. }
  552. /// <inheritdoc />
  553. public void SetShuffleMode(GroupShuffleMode mode)
  554. {
  555. PlayQueue.SetShuffleMode(mode);
  556. }
  557. /// <inheritdoc />
  558. public PlayQueueUpdate GetPlayQueueUpdate(PlayQueueUpdateReason reason)
  559. {
  560. var startPositionTicks = PositionTicks;
  561. if (_state.Type.Equals(GroupStateType.Playing))
  562. {
  563. var currentTime = DateTime.UtcNow;
  564. var elapsedTime = currentTime - LastActivity;
  565. // Elapsed time is negative if event happens
  566. // during the delay added to account for latency.
  567. // In this phase clients haven't started the playback yet.
  568. // In other words, LastActivity is in the future,
  569. // when playback unpause is supposed to happen.
  570. // Adjust ticks only if playback actually started.
  571. startPositionTicks += Math.Max(elapsedTime.Ticks, 0);
  572. }
  573. return new PlayQueueUpdate(
  574. reason,
  575. PlayQueue.LastChange,
  576. PlayQueue.GetPlaylist(),
  577. PlayQueue.PlayingItemIndex,
  578. startPositionTicks,
  579. PlayQueue.ShuffleMode,
  580. PlayQueue.RepeatMode);
  581. }
  582. }
  583. }