@@ -28,9 +28,9 @@ public class VideoPlayerPageViewModel : ViewModelBase, INotifyPropertyChanged, I
2828 private readonly INavigationService _navigationService ;
2929 private readonly GraphHelper graphHelper = GraphHelper . Instance ( ) ;
3030 /// <summary>
31- /// Fires every two minutes to indicate the OneDrive download URL has expired.
31+ /// Fires every time the OneDrive download URL has expired (two minutes) .
3232 /// </summary>
33- private readonly Timer reloadIntervalTimer = new Timer ( 2 * 60 * 1000 ) ;
33+ private readonly Timer reloadIntervalTimer = new Timer ( ) ;
3434 /// <summary>
3535 /// Single-shot timer to hide the filename shortly after playing a video.
3636 /// </summary>
@@ -236,18 +236,16 @@ private async void InitializeLibVLC(InitializedEventArgs eventArgs)
236236 VideoLength = 0 ;
237237 PlayPauseButtonFontIcon = "\xE768 " ;
238238
239- // Create LibVLC instance and subscribe to events .
239+ // Create LibVLC instance.
240240 LibVLC = new LibVLC ( eventArgs . SwapChainOptions ) ;
241241 MediaPlayer = new MediaPlayer ( LibVLC ) ;
242242
243+ // Subscribe to events only once.
243244 MediaPlayer . Playing += MediaPlayer_Playing ;
244245 MediaPlayer . Paused += MediaPlayer_Paused ;
245246 MediaPlayer . TimeChanged += MediaPlayer_TimeChanged ;
246-
247- // Subscribe to the timer events and start the reloadInterval timer.
248- fileNameOverlayTimer . Elapsed += FileNameOverlayTimer_Elapsed ;
249247 reloadIntervalTimer . Elapsed += ReloadIntervalTimer_Elapsed ;
250- reloadIntervalTimer . Start ( ) ;
248+ fileNameOverlayTimer . Elapsed += FileNameOverlayTimer_Elapsed ;
251249
252250 // Finally, play the media.
253251 await PlayMedia ( ) ;
@@ -331,14 +329,21 @@ private async Task PlayMedia(long startTime = 0)
331329 {
332330 CheckPreviousNextMediaInList ( ) ;
333331
334- FileName = MediaWrapper . CachedDriveItem . Name ;
332+ // If the starttime is not 0, a reload is performed, so the filename is
333+ // already set and should stay hidden. The fileNameOverlayTimer should
334+ // also not be reset.
335+ if ( startTime == 0 )
336+ {
337+ FileName = MediaWrapper . CachedDriveItem . Name ;
338+ FileNameOverlayVisiblity = Visibility . Visible ;
335339
336- FileNameOverlayVisiblity = Visibility . Visible ;
340+ fileNameOverlayTimer . Interval = 5 * 1000 ;
341+ fileNameOverlayTimer . Start ( ) ;
342+ }
337343
338- // Reset the interval to 5 seconds again in case the next video is
339- // played within 5 seconds.
340- fileNameOverlayTimer . Interval = 5 * 1000 ;
341- fileNameOverlayTimer . Start ( ) ;
344+ // The reloadIntervalTimer should be reset regardless of a reload.
345+ reloadIntervalTimer . Interval = 2 * 60 * 1000 ;
346+ reloadIntervalTimer . Start ( ) ;
342347
343348 string mediaDownloadURL = await RetrieveDownloadURLMedia ( MediaWrapper ) ;
344349 // Play the OneDrive file.
@@ -451,14 +456,12 @@ private void SetVideoTime(double time)
451456
452457 //TODO: Implement a Dialog system that shows a dialog when there is an error.
453458 /// <summary>
454- /// Tries to restart the media that is currently playing .
459+ /// Restart the media from the currently timestamp .
455460 /// </summary>
456461 private async void ReloadCurrentMedia ( )
457462 {
458463 await PlayMedia ( TimeLineValue ) ;
459- reloadIntervalTimer . Stop ( ) ; //In case a user reloads with the reload button. Stop the timer so we dont get multiple running.
460464 InvalidOneDriveSession = false ;
461- reloadIntervalTimer . Start ( ) ;
462465 }
463466
464467 /// <summary>
0 commit comments