@@ -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,19 @@ 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 ;
249+
250+ // Start the filenameoverlay timer.
251+ fileNameOverlayTimer . Start ( ) ;
251252
252253 // Finally, play the media.
253254 await PlayMedia ( ) ;
@@ -331,14 +332,20 @@ private async Task PlayMedia(long startTime = 0)
331332 {
332333 CheckPreviousNextMediaInList ( ) ;
333334
334- FileName = MediaWrapper . CachedDriveItem . Name ;
335-
336- FileNameOverlayVisiblity = Visibility . Visible ;
335+ // If the starttime is not 0, a reload is performed, so the filename
336+ // is already set and should stay hidden.
337+ if ( startTime == 0 )
338+ {
339+ FileName = MediaWrapper . CachedDriveItem . Name ;
340+ FileNameOverlayVisiblity = Visibility . Visible ;
341+ }
337342
338- // Reset the interval to 5 seconds again in case the next video is
339- // played within 5 seconds.
343+ // Reset the timer intervals. Only restart the reloadIntervalTimer,
344+ // since the filename shouldn't be displayed in case of a reload of
345+ // the current video.
340346 fileNameOverlayTimer . Interval = 5 * 1000 ;
341- fileNameOverlayTimer . Start ( ) ;
347+ reloadIntervalTimer . Interval = 2 * 60 * 1000 ;
348+ reloadIntervalTimer . Start ( ) ;
342349
343350 string mediaDownloadURL = await RetrieveDownloadURLMedia ( MediaWrapper ) ;
344351 // Play the OneDrive file.
@@ -451,14 +458,12 @@ private void SetVideoTime(double time)
451458
452459 //TODO: Implement a Dialog system that shows a dialog when there is an error.
453460 /// <summary>
454- /// Tries to restart the media that is currently playing .
461+ /// Restart the media from the currently timestamp .
455462 /// </summary>
456463 private async void ReloadCurrentMedia ( )
457464 {
458465 await PlayMedia ( TimeLineValue ) ;
459- reloadIntervalTimer . Stop ( ) ; //In case a user reloads with the reload button. Stop the timer so we dont get multiple running.
460466 InvalidOneDriveSession = false ;
461- reloadIntervalTimer . Start ( ) ;
462467 }
463468
464469 /// <summary>
@@ -541,6 +546,7 @@ private async void PlayPreviousVideo()
541546
542547 MediaWrapper . CachedDriveItem = App . Current . MediaItemList [ -- MediaListIndex ] ;
543548 await PlayMedia ( ) ;
549+ fileNameOverlayTimer . Start ( ) ;
544550 }
545551
546552 /// <summary>
@@ -555,6 +561,7 @@ private async void PlayNextVideo()
555561
556562 MediaWrapper . CachedDriveItem = App . Current . MediaItemList [ ++ MediaListIndex ] ;
557563 await PlayMedia ( ) ;
564+ fileNameOverlayTimer . Start ( ) ;
558565 }
559566
560567 /// <summary>
0 commit comments