public async Task ReplayLastAsync() { if (!player.IsAvailable) { return; } if (playedVideos.Count > 1) { Media LastVideo = PlayerAccess.GetVideoById(playedVideos[playedVideos.Count - 2]); if (LastVideo.MediaId != player.CurrentVideo.MediaId) { playedVideos.RemoveAt(playedVideos.Count - 1); if (nextVideo != null) { CancelNextDownload(nextVideo); } nextVideo = player.CurrentVideo; // Enable/Disable SVP if necessary. MpcConfigBusiness.AutoConfigure(nextVideo); // Auto-pitch to 432hz bool EnableAutoPitch = AutoPitchBusiness.AppyAutoPitch(LastVideo); await player.PlayVideoAsync(LastVideo, EnableAutoPitch).ConfigureAwait(false); Application.Current.Dispatcher.Invoke(() => PlaylistChanged?.Invoke(this, new EventArgs())); } } }
/// <summary> /// Plays a single video while allowing to close the player, such as from the Edit Video window. /// </summary> /// <param name="fileName">The name of the file to play.</param> public async Task PlaySingleVideoAsync(string fileName) { Media video = GetMediaObject(fileName); if (!player.IsAvailable || video == null) { return; } if (nextVideo != null) { CancelNextDownload(nextVideo); NextVideoOptions.Clear(); nextVideo = video; } // Enable/Disable SVP if necessary. MpcConfigBusiness.AutoConfigure(video); // Auto-pitch to 432hz bool EnableAutoPitch = AutoPitchBusiness.AppyAutoPitch(video); await player.PlayVideoAsync(video, EnableAutoPitch).ConfigureAwait(false); Application.Current.Dispatcher.Invoke(() => PlaylistChanged?.Invoke(this, new EventArgs())); }
/// <summary> /// Closes the video player. /// </summary> public void ClosePlayer() { if (player != null) { player.Close(); } MpcConfigBusiness.ClearLog(); }
/// <summary> /// Enable/Disable SVP and madVR if necessary. /// </summary> public void ConfigurePlayer() { if (Settings.SavedFile.MediaPlayerApp == MediaPlayerApplication.Mpc) { if (CurrentVideo != null) { MpcConfigBusiness.AutoConfigure(CurrentVideo); } else { MpcConfigBusiness.AutoConfigure(null); } } }
/// <summary> /// Plays the next video. /// </summary> private async Task PlayNextVideoAsync() { if (nextVideo == null) { return; } // Enable/Disable SVP if necessary. MpcConfigBusiness.AutoConfigure(nextVideo); // If next video is still downloading, advance QueuePos. If QueuePos = 0 when download finishes, it will auto-play. var VideoDownload = GetNextVideoDownloading(); if (VideoDownload != null) { DownloadItemData IData = VideoDownload.Data as DownloadItemData; if (IData.QueuePos > 0) { IData.QueuePos--; } return; } // Auto-pitch to 432hz bool EnableAutoPitch = AutoPitchBusiness.AppyAutoPitch(nextVideo); await player.PlayVideoAsync(nextVideo, EnableAutoPitch).ConfigureAwait(false); playedVideos.Add(nextVideo.MediaId); nextVideo = null; if (PlayMode == PlayerMode.SpecialRequest) { PlayMode = PlayerMode.Normal; } if (playMode != PlayerMode.Manual) { await SelectNextVideoAsync(1, false).ConfigureAwait(false); } if (PlayMode == PlayerMode.Fire) { PlayMode = PlayerMode.SpecialRequest; } Application.Current.Dispatcher.Invoke(() => PlaylistChanged?.Invoke(this, new EventArgs())); }