/// <summary> /// Mets en pause la vidéo et les sous-titres (le sous-titre en cours d'affichage ne se fige pas, d'où le décalage à la reprise) /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void PauseVideo(object sender, RoutedEventArgs e) { if (VideoPlaying != null && VideoPlaying.Source != null && IsPlaying) { VideoPlaying.Pause(); IsPlaying = false; IsPaused = true; if (Token != null) { Token.Cancel(); } } }
/// <summary> /// Arrête la vidéo et les sous-titres /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void StopVideo(object sender, RoutedEventArgs e) { if (VideoPlaying != null && VideoPlaying.Source != null) { VideoPlaying.Stop(); IsPlaying = false; IsSubTaskRunning = false; if (Token != null) { Token.Cancel(); } } }
/// <summary> /// Lance la lecture de la vidéo et des sous-titres /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private async void PlayVideo(object sender, RoutedEventArgs e) { if (VideoPlaying != null && VideoPlaying.Source != null && !IsPlaying) { VideoPlaying.Play(); Timer.Start(); IsPlaying = true; if (Subs != null && (!IsSubTaskRunning || IsPaused)) { IsSubTaskRunning = true; Token = new CancellationTokenSource(); if (IsPaused) { await Task.WhenAll(Subs.DisplaySubtitles(Subtitles, VideoPlaying, Token.Token, true)); } else { await Task.WhenAll(Subs.DisplaySubtitles(Subtitles, VideoPlaying, Token.Token, false)); } } } }