GroupController.cs 23 KB

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