BaseMediaPlayer.cs 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748
  1. using MediaBrowser.Common.Events;
  2. using MediaBrowser.Common.Logging;
  3. using MediaBrowser.Model.Dto;
  4. using MediaBrowser.Model.Logging;
  5. using MediaBrowser.Model.Net;
  6. using MediaBrowser.UI.Configuration;
  7. using MediaBrowser.UI.Controller;
  8. using System;
  9. using System.Collections.Generic;
  10. using System.Linq;
  11. using System.Threading;
  12. using System.Threading.Tasks;
  13. namespace MediaBrowser.UI.Playback
  14. {
  15. /// <summary>
  16. /// Class BaseMediaPlayer
  17. /// </summary>
  18. public abstract class BaseMediaPlayer : IDisposable
  19. {
  20. /// <summary>
  21. /// Gets the logger.
  22. /// </summary>
  23. /// <value>The logger.</value>
  24. protected ILogger Logger { get; private set; }
  25. #region VolumeChanged
  26. /// <summary>
  27. /// Occurs when [volume changed].
  28. /// </summary>
  29. public event EventHandler VolumeChanged;
  30. protected void OnVolumeChanged()
  31. {
  32. EventHelper.FireEventIfNotNull(VolumeChanged, this, EventArgs.Empty);
  33. }
  34. #endregion
  35. #region PlayStateChanged
  36. /// <summary>
  37. /// Occurs when [play state changed].
  38. /// </summary>
  39. public event EventHandler PlayStateChanged;
  40. protected void OnPlayStateChanged()
  41. {
  42. EventHelper.FireEventIfNotNull(PlayStateChanged, this, EventArgs.Empty);
  43. }
  44. #endregion
  45. /// <summary>
  46. /// The null task result
  47. /// </summary>
  48. protected Task<bool> NullTaskResult = Task.FromResult(false);
  49. /// <summary>
  50. /// Gets a value indicating whether [supports multi file playback].
  51. /// </summary>
  52. /// <value><c>true</c> if [supports multi file playback]; otherwise, <c>false</c>.</value>
  53. public abstract bool SupportsMultiFilePlayback { get; }
  54. /// <summary>
  55. /// The currently playing items
  56. /// </summary>
  57. public List<BaseItemDto> Playlist = new List<BaseItemDto>();
  58. /// <summary>
  59. /// The _play state
  60. /// </summary>
  61. private PlayState _playState;
  62. /// <summary>
  63. /// Gets or sets the state of the play.
  64. /// </summary>
  65. /// <value>The state of the play.</value>
  66. public PlayState PlayState
  67. {
  68. get
  69. {
  70. return _playState;
  71. }
  72. set
  73. {
  74. _playState = value;
  75. OnPlayStateChanged();
  76. }
  77. }
  78. /// <summary>
  79. /// Gets or sets a value indicating whether this <see cref="BaseMediaPlayer" /> is mute.
  80. /// </summary>
  81. /// <value><c>true</c> if mute; otherwise, <c>false</c>.</value>
  82. public bool Mute
  83. {
  84. get { return IsMuted; }
  85. set
  86. {
  87. SetMute(value);
  88. OnVolumeChanged();
  89. }
  90. }
  91. /// <summary>
  92. /// Gets or sets the volume.
  93. /// </summary>
  94. /// <value>The volume.</value>
  95. public int Volume
  96. {
  97. get { return GetVolume(); }
  98. set
  99. {
  100. SetVolume(value);
  101. OnVolumeChanged();
  102. }
  103. }
  104. /// <summary>
  105. /// Gets the current player configuration.
  106. /// </summary>
  107. /// <value>The current player configuration.</value>
  108. public PlayerConfiguration CurrentPlayerConfiguration { get; private set; }
  109. /// <summary>
  110. /// Gets the current play options.
  111. /// </summary>
  112. /// <value>The current play options.</value>
  113. public PlayOptions CurrentPlayOptions { get; private set; }
  114. /// <summary>
  115. /// Gets the name.
  116. /// </summary>
  117. /// <value>The name.</value>
  118. public abstract string Name { get; }
  119. /// <summary>
  120. /// Determines whether this instance can play the specified item.
  121. /// </summary>
  122. /// <param name="item">The item.</param>
  123. /// <returns><c>true</c> if this instance can play the specified item; otherwise, <c>false</c>.</returns>
  124. public abstract bool CanPlay(BaseItemDto item);
  125. /// <summary>
  126. /// Gets a value indicating whether this instance can change volume.
  127. /// </summary>
  128. /// <value><c>true</c> if this instance can change volume; otherwise, <c>false</c>.</value>
  129. public abstract bool CanControlVolume { get; }
  130. /// <summary>
  131. /// Gets a value indicating whether this instance can mute.
  132. /// </summary>
  133. /// <value><c>true</c> if this instance can mute; otherwise, <c>false</c>.</value>
  134. public abstract bool CanMute { get; }
  135. /// <summary>
  136. /// Gets a value indicating whether this instance can queue.
  137. /// </summary>
  138. /// <value><c>true</c> if this instance can queue; otherwise, <c>false</c>.</value>
  139. public abstract bool CanQueue { get; }
  140. /// <summary>
  141. /// Gets a value indicating whether this instance can pause.
  142. /// </summary>
  143. /// <value><c>true</c> if this instance can pause; otherwise, <c>false</c>.</value>
  144. public abstract bool CanPause { get; }
  145. /// <summary>
  146. /// Gets a value indicating whether this instance can seek.
  147. /// </summary>
  148. /// <value><c>true</c> if this instance can seek; otherwise, <c>false</c>.</value>
  149. public abstract bool CanSeek { get; }
  150. /// <summary>
  151. /// Gets the index of the current playlist.
  152. /// </summary>
  153. /// <value>The index of the current playlist.</value>
  154. public virtual int CurrentPlaylistIndex
  155. {
  156. get { return 0; }
  157. }
  158. /// <summary>
  159. /// Gets the current media.
  160. /// </summary>
  161. /// <value>The current media.</value>
  162. public BaseItemDto CurrentMedia
  163. {
  164. get
  165. {
  166. return CurrentPlaylistIndex == -1 ? null : Playlist[CurrentPlaylistIndex];
  167. }
  168. }
  169. /// <summary>
  170. /// Gets the current position ticks.
  171. /// </summary>
  172. /// <value>The current position ticks.</value>
  173. public virtual long? CurrentPositionTicks
  174. {
  175. get
  176. {
  177. return null;
  178. }
  179. }
  180. /// <summary>
  181. /// Gets a value indicating whether this instance is muted.
  182. /// </summary>
  183. /// <value><c>true</c> if this instance is muted; otherwise, <c>false</c>.</value>
  184. protected virtual bool IsMuted
  185. {
  186. get { return false; }
  187. }
  188. /// <summary>
  189. /// Initializes a new instance of the <see cref="BaseMediaPlayer" /> class.
  190. /// </summary>
  191. protected BaseMediaPlayer()
  192. {
  193. Logger = LogManager.GetLogger(GetType().Name);
  194. }
  195. /// <summary>
  196. /// Sets the mute.
  197. /// </summary>
  198. /// <param name="mute">if set to <c>true</c> [mute].</param>
  199. protected virtual void SetMute(bool mute)
  200. {
  201. }
  202. /// <summary>
  203. /// Sets the volume, on a scale from 0-100
  204. /// </summary>
  205. /// <param name="value">The value.</param>
  206. protected virtual void SetVolume(int value)
  207. {
  208. }
  209. /// <summary>
  210. /// Gets the volume.
  211. /// </summary>
  212. /// <returns>System.Int32.</returns>
  213. protected virtual int GetVolume()
  214. {
  215. return 0;
  216. }
  217. /// <summary>
  218. /// Plays the internal.
  219. /// </summary>
  220. /// <param name="items">The items.</param>
  221. /// <param name="options">The options.</param>
  222. /// <param name="playerConfiguration">The player configuration.</param>
  223. protected abstract void PlayInternal(List<BaseItemDto> items, PlayOptions options, PlayerConfiguration playerConfiguration);
  224. /// <summary>
  225. /// Queues the internal.
  226. /// </summary>
  227. /// <param name="items">The items.</param>
  228. protected virtual void QueueInternal(List<BaseItemDto> items)
  229. {
  230. }
  231. /// <summary>
  232. /// Stops the internal.
  233. /// </summary>
  234. /// <returns>Task.</returns>
  235. protected abstract Task StopInternal();
  236. /// <summary>
  237. /// The play semaphore
  238. /// </summary>
  239. private readonly SemaphoreSlim PlaySemaphore = new SemaphoreSlim(1, 1);
  240. /// <summary>
  241. /// Gets or sets the progress update timer.
  242. /// </summary>
  243. /// <value>The progress update timer.</value>
  244. private Timer ProgressUpdateTimer { get; set; }
  245. /// <summary>
  246. /// Gets a value indicating whether this instance can monitor progress.
  247. /// </summary>
  248. /// <value><c>true</c> if this instance can monitor progress; otherwise, <c>false</c>.</value>
  249. protected virtual bool CanMonitorProgress
  250. {
  251. get
  252. {
  253. return false;
  254. }
  255. }
  256. /// <summary>
  257. /// Stops this instance.
  258. /// </summary>
  259. /// <returns>Task.</returns>
  260. /// <exception cref="System.InvalidOperationException"></exception>
  261. public Task Stop()
  262. {
  263. var playstate = PlayState;
  264. if (playstate == PlayState.Playing || playstate == PlayState.Paused)
  265. {
  266. Logger.Info("Stopping");
  267. return StopInternal();
  268. }
  269. throw new InvalidOperationException(string.Format("{0} is already {1}", Name, playstate));
  270. }
  271. /// <summary>
  272. /// Plays the specified item.
  273. /// </summary>
  274. /// <param name="options">The options.</param>
  275. /// <param name="playerConfiguration">The player configuration.</param>
  276. /// <returns>Task.</returns>
  277. /// <exception cref="System.ArgumentNullException">items</exception>
  278. internal async Task Play(PlayOptions options, PlayerConfiguration playerConfiguration)
  279. {
  280. if (options == null)
  281. {
  282. throw new ArgumentNullException("options");
  283. }
  284. await PlaySemaphore.WaitAsync();
  285. PlayState = PlayState.Playing;
  286. lock (Playlist)
  287. {
  288. Playlist.Clear();
  289. Playlist.AddRange(options.Items);
  290. }
  291. CurrentPlayerConfiguration = playerConfiguration;
  292. CurrentPlayOptions = options;
  293. if (options.Items.Count > 1)
  294. {
  295. Logger.Info("Playing {0} items", options.Items.Count);
  296. }
  297. else
  298. {
  299. Logger.Info("Playing {0}", options.Items[0].Name);
  300. }
  301. try
  302. {
  303. PlayInternal(options.Items, options, playerConfiguration);
  304. }
  305. catch (Exception ex)
  306. {
  307. Logger.Info("Error beginning playback", ex);
  308. CurrentPlayerConfiguration = null;
  309. CurrentPlayOptions = null;
  310. Playlist.Clear();
  311. PlayState = PlayState.Idle;
  312. PlaySemaphore.Release();
  313. throw;
  314. }
  315. SendPlaybackStartCheckIn(options.Items[0]);
  316. ReloadProgressUpdateTimer();
  317. }
  318. /// <summary>
  319. /// Restarts the progress update timer.
  320. /// </summary>
  321. private void ReloadProgressUpdateTimer()
  322. {
  323. ProgressUpdateTimer = new Timer(OnProgressTimerStopped, null, TimeSpan.FromSeconds(5), TimeSpan.FromSeconds(10));
  324. }
  325. /// <summary>
  326. /// Called when [progress timer stopped].
  327. /// </summary>
  328. /// <param name="state">The state.</param>
  329. private void OnProgressTimerStopped(object state)
  330. {
  331. var index = CurrentPlaylistIndex;
  332. if (index != -1)
  333. {
  334. SendPlaybackProgressCheckIn(Playlist[index], CurrentPositionTicks);
  335. }
  336. }
  337. /// <summary>
  338. /// Queues the specified items.
  339. /// </summary>
  340. /// <param name="items">The items.</param>
  341. /// <exception cref="System.ArgumentNullException">items</exception>
  342. /// <exception cref="System.InvalidOperationException"></exception>
  343. internal void Queue(List<BaseItemDto> items)
  344. {
  345. if (items == null)
  346. {
  347. throw new ArgumentNullException("items");
  348. }
  349. var playstate = PlayState;
  350. if (playstate != PlayState.Playing && playstate != PlayState.Paused)
  351. {
  352. throw new InvalidOperationException(string.Format("{0} cannot queue from playstate: {1}", Name, playstate));
  353. }
  354. lock (Playlist)
  355. {
  356. Playlist.AddRange(items);
  357. }
  358. QueueInternal(items);
  359. }
  360. /// <summary>
  361. /// Called when [player stopped].
  362. /// </summary>
  363. /// <param name="lastPlaylistIndex">Last index of the playlist.</param>
  364. /// <param name="positionTicks">The position ticks.</param>
  365. protected void OnPlayerStopped(int? lastPlaylistIndex, long? positionTicks)
  366. {
  367. Logger.Info("Stopped");
  368. if (positionTicks.HasValue && positionTicks.Value == 0)
  369. {
  370. positionTicks = null;
  371. }
  372. var items = Playlist.ToList();
  373. DisposeProgressUpdateTimer();
  374. var index = lastPlaylistIndex ?? CurrentPlaylistIndex;
  375. var lastItem = items[index];
  376. SendPlaybackStopCheckIn(items[index], positionTicks);
  377. if (!CanMonitorProgress)
  378. {
  379. if (items.Count > 1)
  380. {
  381. MarkWatched(items.Except(new[] { lastItem }));
  382. }
  383. }
  384. OnPlayerStoppedInternal();
  385. UIKernel.Instance.PlaybackManager.OnPlaybackCompleted(this, Playlist.ToList());
  386. CurrentPlayerConfiguration = null;
  387. CurrentPlayOptions = null;
  388. Logger.Info("Clearing Playlist");
  389. Playlist.Clear();
  390. PlayState = PlayState.Idle;
  391. PlaySemaphore.Release();
  392. }
  393. /// <summary>
  394. /// Called when [player stopped internal].
  395. /// </summary>
  396. protected virtual void OnPlayerStoppedInternal()
  397. {
  398. }
  399. /// <summary>
  400. /// Seeks the specified position ticks.
  401. /// </summary>
  402. /// <param name="positionTicks">The position ticks.</param>
  403. /// <returns>Task.</returns>
  404. /// <exception cref="System.InvalidOperationException"></exception>
  405. public async Task Seek(long positionTicks)
  406. {
  407. var playState = PlayState;
  408. if (playState == PlayState.Playing || playState == PlayState.Paused)
  409. {
  410. await SeekInternal(positionTicks);
  411. }
  412. else
  413. {
  414. throw new InvalidOperationException(string.Format("Cannot seek {0} with playstate {1}", Name, PlayState));
  415. }
  416. }
  417. /// <summary>
  418. /// Seeks the internal.
  419. /// </summary>
  420. /// <param name="positionTicks">The position ticks.</param>
  421. /// <returns>Task.</returns>
  422. protected virtual Task SeekInternal(long positionTicks)
  423. {
  424. return NullTaskResult;
  425. }
  426. /// <summary>
  427. /// The ten seconds
  428. /// </summary>
  429. private static readonly long TenSeconds = TimeSpan.FromSeconds(10).Ticks;
  430. /// <summary>
  431. /// Goes to next chapter.
  432. /// </summary>
  433. /// <returns>Task.</returns>
  434. public virtual Task GoToNextChapter()
  435. {
  436. var current = CurrentPositionTicks;
  437. var chapter = CurrentMedia.Chapters.FirstOrDefault(c => c.StartPositionTicks > current);
  438. return chapter != null ? Seek(chapter.StartPositionTicks) : NullTaskResult;
  439. }
  440. /// <summary>
  441. /// Goes to previous chapter.
  442. /// </summary>
  443. /// <returns>Task.</returns>
  444. public virtual Task GoToPreviousChapter()
  445. {
  446. var current = CurrentPositionTicks;
  447. var chapter = CurrentMedia.Chapters.LastOrDefault(c => c.StartPositionTicks < current - TenSeconds);
  448. return chapter != null ? Seek(chapter.StartPositionTicks) : NullTaskResult;
  449. }
  450. /// <summary>
  451. /// Pauses this instance.
  452. /// </summary>
  453. /// <returns>Task.</returns>
  454. /// <exception cref="System.InvalidOperationException"></exception>
  455. public async Task Pause()
  456. {
  457. if (PlayState == PlayState.Playing)
  458. {
  459. await PauseInternal();
  460. PlayState = PlayState.Paused;
  461. }
  462. else
  463. {
  464. throw new InvalidOperationException(string.Format("Cannot pause {0} with playstate {1}", Name, PlayState));
  465. }
  466. }
  467. /// <summary>
  468. /// Pauses the internal.
  469. /// </summary>
  470. /// <returns>Task.</returns>
  471. protected virtual Task PauseInternal()
  472. {
  473. return NullTaskResult;
  474. }
  475. /// <summary>
  476. /// Uns the pause.
  477. /// </summary>
  478. /// <returns>Task.</returns>
  479. /// <exception cref="System.InvalidOperationException"></exception>
  480. public async Task UnPause()
  481. {
  482. if (PlayState == PlayState.Paused)
  483. {
  484. await UnPauseInternal();
  485. PlayState = PlayState.Playing;
  486. }
  487. else
  488. {
  489. throw new InvalidOperationException(string.Format("Cannot unpause {0} with playstate {1}", Name, PlayState));
  490. }
  491. }
  492. /// <summary>
  493. /// Uns the pause internal.
  494. /// </summary>
  495. /// <returns>Task.</returns>
  496. protected virtual Task UnPauseInternal()
  497. {
  498. return NullTaskResult;
  499. }
  500. /// <summary>
  501. /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
  502. /// </summary>
  503. public void Dispose()
  504. {
  505. Dispose(true);
  506. }
  507. /// <summary>
  508. /// Releases unmanaged and - optionally - managed resources.
  509. /// </summary>
  510. /// <param name="dispose"><c>true</c> to release both managed and unmanaged resources; <c>false</c> to release only unmanaged resources.</param>
  511. protected virtual void Dispose(bool dispose)
  512. {
  513. Logger.Info("Disposing");
  514. DisposeProgressUpdateTimer();
  515. if (PlayState == PlayState.Playing || PlayState == PlayState.Paused)
  516. {
  517. var index = CurrentPlaylistIndex;
  518. if (index != -1)
  519. {
  520. SendPlaybackStopCheckIn(Playlist[index], CurrentPositionTicks);
  521. }
  522. Task.Run(() => Stop());
  523. Thread.Sleep(1000);
  524. }
  525. PlaySemaphore.Dispose();
  526. }
  527. /// <summary>
  528. /// Disposes the progress update timer.
  529. /// </summary>
  530. private void DisposeProgressUpdateTimer()
  531. {
  532. if (ProgressUpdateTimer != null)
  533. {
  534. ProgressUpdateTimer.Dispose();
  535. }
  536. }
  537. /// <summary>
  538. /// Sends the playback start check in.
  539. /// </summary>
  540. /// <param name="item">The item.</param>
  541. protected async void SendPlaybackStartCheckIn(BaseItemDto item)
  542. {
  543. if (string.IsNullOrEmpty(item.Id))
  544. {
  545. return;
  546. }
  547. Logger.Info("Sending playback start checkin for {0}", item.Name);
  548. try
  549. {
  550. await UIKernel.Instance.ApiClient.ReportPlaybackStartAsync(item.Id, App.Instance.CurrentUser.Id);
  551. }
  552. catch (HttpException ex)
  553. {
  554. Logger.ErrorException("Error sending playback start checking for {0}", ex, item.Name);
  555. }
  556. }
  557. /// <summary>
  558. /// Sends the playback progress check in.
  559. /// </summary>
  560. /// <param name="item">The item.</param>
  561. /// <param name="positionTicks">The position ticks.</param>
  562. protected async void SendPlaybackProgressCheckIn(BaseItemDto item, long? positionTicks)
  563. {
  564. if (string.IsNullOrEmpty(item.Id))
  565. {
  566. return;
  567. }
  568. var position = positionTicks.HasValue ? TimeSpan.FromTicks(positionTicks.Value).ToString() : "unknown";
  569. Logger.Info("Sending playback progress checkin for {0} at position {1}", item.Name, position);
  570. try
  571. {
  572. await UIKernel.Instance.ApiClient.ReportPlaybackProgressAsync(item.Id, App.Instance.CurrentUser.Id, positionTicks);
  573. }
  574. catch (HttpException ex)
  575. {
  576. Logger.ErrorException("Error sending playback progress checking for {0}", ex, item.Name);
  577. }
  578. }
  579. /// <summary>
  580. /// Sends the playback stop check in.
  581. /// </summary>
  582. /// <param name="item">The item.</param>
  583. /// <param name="positionTicks">The position ticks.</param>
  584. protected async void SendPlaybackStopCheckIn(BaseItemDto item, long? positionTicks)
  585. {
  586. if (string.IsNullOrEmpty(item.Id))
  587. {
  588. return;
  589. }
  590. var position = positionTicks.HasValue ? TimeSpan.FromTicks(positionTicks.Value).ToString() : "unknown";
  591. Logger.Info("Sending playback stop checkin for {0} at position {1}", item.Name, position);
  592. try
  593. {
  594. await UIKernel.Instance.ApiClient.ReportPlaybackStoppedAsync(item.Id, App.Instance.CurrentUser.Id, positionTicks);
  595. }
  596. catch (HttpException ex)
  597. {
  598. Logger.ErrorException("Error sending playback stop checking for {0}", ex, item.Name);
  599. }
  600. }
  601. /// <summary>
  602. /// Marks the watched.
  603. /// </summary>
  604. /// <param name="items">The items.</param>
  605. protected async void MarkWatched(IEnumerable<BaseItemDto> items)
  606. {
  607. var idList = items.Where(i => !string.IsNullOrEmpty(i.Id)).Select(i => i.Id);
  608. try
  609. {
  610. await UIKernel.Instance.ApiClient.UpdatePlayedStatusAsync(idList.First(), App.Instance.CurrentUser.Id, true);
  611. }
  612. catch (HttpException ex)
  613. {
  614. Logger.ErrorException("Error marking items watched", ex);
  615. }
  616. }
  617. /// <summary>
  618. /// Called when [media changed].
  619. /// </summary>
  620. /// <param name="oldPlaylistIndex">Old index of the playlist.</param>
  621. /// <param name="endingPositionTicks">The ending position ticks.</param>
  622. /// <param name="newPlaylistIndex">New index of the playlist.</param>
  623. protected void OnMediaChanged(int oldPlaylistIndex, long? endingPositionTicks, int newPlaylistIndex)
  624. {
  625. DisposeProgressUpdateTimer();
  626. Task.Run(() =>
  627. {
  628. if (oldPlaylistIndex != -1)
  629. {
  630. SendPlaybackStopCheckIn(Playlist[oldPlaylistIndex], endingPositionTicks);
  631. }
  632. if (newPlaylistIndex != -1)
  633. {
  634. SendPlaybackStartCheckIn(Playlist[newPlaylistIndex]);
  635. }
  636. });
  637. ReloadProgressUpdateTimer();
  638. }
  639. }
  640. }