GroupController.cs 23 KB

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