Skip to content

Commit 5f15eec

Browse files
Simplified reset of filenameOverlay timer.
VideoPlayerPageViewModel.cs: - refac: Since the check for a reload is already done in PlayMedia(), it makes sense to start the timer there as well instead of in the three places in the codebase where PlayMedia() gets called with a default timeline value.
1 parent 8696d3e commit 5f15eec

File tree

1 file changed

+7
-11
lines changed

1 file changed

+7
-11
lines changed

OneDrive-Cloud-Player/ViewModels/VideoPlayerPageViewModel.cs

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -247,9 +247,6 @@ private async void InitializeLibVLC(InitializedEventArgs eventArgs)
247247
reloadIntervalTimer.Elapsed += ReloadIntervalTimer_Elapsed;
248248
fileNameOverlayTimer.Elapsed += FileNameOverlayTimer_Elapsed;
249249

250-
// Start the filenameoverlay timer.
251-
fileNameOverlayTimer.Start();
252-
253250
// Finally, play the media.
254251
await PlayMedia();
255252
}
@@ -332,18 +329,19 @@ private async Task PlayMedia(long startTime = 0)
332329
{
333330
CheckPreviousNextMediaInList();
334331

335-
// If the starttime is not 0, a reload is performed, so the filename
336-
// is already set and should stay hidden.
332+
// If the starttime is not 0, a reload is performed, so the filename is
333+
// already set and should stay hidden. The fileNameOverlayTimer shoud
334+
// also not be reset.
337335
if (startTime == 0)
338336
{
339337
FileName = MediaWrapper.CachedDriveItem.Name;
340338
FileNameOverlayVisiblity = Visibility.Visible;
339+
340+
fileNameOverlayTimer.Interval = 5 * 1000;
341+
fileNameOverlayTimer.Start();
341342
}
342343

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.
346-
fileNameOverlayTimer.Interval = 5 * 1000;
344+
// The reloadIntervalTimer should be reset regardless of a reload.
347345
reloadIntervalTimer.Interval = 2 * 60 * 1000;
348346
reloadIntervalTimer.Start();
349347

@@ -546,7 +544,6 @@ private async void PlayPreviousVideo()
546544

547545
MediaWrapper.CachedDriveItem = App.Current.MediaItemList[--MediaListIndex];
548546
await PlayMedia();
549-
fileNameOverlayTimer.Start();
550547
}
551548

552549
/// <summary>
@@ -561,7 +558,6 @@ private async void PlayNextVideo()
561558

562559
MediaWrapper.CachedDriveItem = App.Current.MediaItemList[++MediaListIndex];
563560
await PlayMedia();
564-
fileNameOverlayTimer.Start();
565561
}
566562

567563
/// <summary>

0 commit comments

Comments
 (0)