public MpvVideoBar() { InitializeComponent(); this.Resize += OnResize; trackBarPosition.MouseDown += (s, e) => { dragging = true; mpvPlayer.Pause(); trackBarPosition.SetValueToMousePosition(e); }; trackBarPosition.MouseMove += (s, e) => { if (!setDraggingToFalse) // while this is true this means that the mouse is no longer being held down { if (dragging) { trackBarPosition.SetValueToMousePosition(e); } } }; trackBarPosition.MouseUp += (s, e) => { setDraggingToFalse = true; // this delays the ability to tell the program that dragging is false, preventing quick clicks/drags from being unidentified if (playing) { mpvPlayer.Resume(); } }; }
private void ReloadWallpaper() { if (Wallpaper != null && player != null) { player.Load(Wallpaper.AbsolutePath); player.Resume(); } }
void BtnPlay_Click(object sender, RoutedEventArgs e) { if (player.IsPlaying) { player.Pause(); } else { player.Resume(); } }
private void Form1_Load(object sender, EventArgs e) { switch (platform) { case "a": case "A": case "ac": case "AC": case "AcFun": case "ACFun": player.Load($@"{AcFunLiveServer.Server.Address}/{id}"); break; case "b": case "B": case "bili": case "Bili": case "bilibili": case "Bilibili": case "BiliBili": player.Load($@"{BilibiliLiveServer.Server.Address}/{id}"); break; default: Close(); break; } player.Resume(); }
private void PlayPauseSimpleButton_ClickForPlay(object sender, EventArgs e) { _player.Resume(); playPauseSimpleButton.Image = Properties.Resources.pause; playPauseSimpleButton.Click -= PlayPauseSimpleButton_ClickForPlay; playPauseSimpleButton.Click += PlayPauseSimpleButton_ClickForPause; }
private void SetFile_Click(object sender, RoutedEventArgs e) { OpenFileDialog Fdialog = new OpenFileDialog(); Fdialog.Filter = "Video Files (*.mp4 *.avi *.flv *.gif *.wmv *.amv )|*.mp4;*.avi;*.flv;*.gif;*.wmv;*.amv;" + "|All Files|*.*"; if (Fdialog.ShowDialog() == System.Windows.Forms.DialogResult.OK) { SetUri.IsEnabled = false; filePath = Fdialog.FileName; fileName = Path.GetFileNameWithoutExtension(Fdialog.FileName); Console.WriteLine(filePath); Console.WriteLine(fileName); PathLabel.Content = filePath; Title.Text = fileName; Save.IsEnabled = true; player.Load(filePath); player.Resume(); } }
public MainWindow() { InitializeComponent(); player = new MpvPlayer(PlayerHost.Handle) { Loop = true, Volume = 50 }; player.Load("http://techslides.com/demos/sample-videos/small.mp4"); player.Resume(); }
public VideoPlayerForm(string videoPath, bool allowSkippingForward = true) { _allowSkippingForward = allowSkippingForward; InitializeComponent(); if (!_allowSkippingForward) { skipForwardSimpleButton.Enabled = false; } if (videoPath is null || string.IsNullOrWhiteSpace(videoPath) || !File.Exists(videoPath)) { MessageBox.Show("There was an error loading this video, the player will now close.", "Error Loading Video", MessageBoxButtons.OK, MessageBoxIcon.Error); Close(); return; } videoEditorControlsPanel.Location = new Point(0, Height); _hideTimer = new System.Timers.Timer { Interval = 4000 }; _hideTimer.Elapsed += _hideTimer_Elapsed; _hideTimer.Enabled = true; _exitButtonTimer = new System.Timers.Timer { Interval = 4000 }; _exitButtonTimer.Elapsed += _exitButtonTimer_Elapsed; _exitButtonTimer.Enabled = true; _exitButtonTimer.Start(); var tempPathLocation = $@"{Path.GetTempPath()}{Guid.NewGuid()}mpv-1.dll"; File.Copy($@"{Environment.CurrentDirectory}\mpv-1.txt", tempPathLocation); _player = new MpvPlayer(videoPlayerPanel.Handle, tempPathLocation) { Volume = 100 }; _player.Load(videoPath); _player.PositionChanged += _player_PositionChanged; _player.MediaLoaded += _player_MediaLoaded; _player.MediaFinished += _player_MediaFinished; _player.Resume(); playPauseSimpleButton.Click += PlayPauseSimpleButton_ClickForPause; }
private void MediaLoaded(object sender, EventArgs e) { if (!isChannel && player.Duration.TotalSeconds > 0) { ParseTracksAndSetDefaults(); seekBar.Invoke((System.Threading.ThreadStart) delegate { seekBar.Enabled = true; seekBar.Value = 0; seekBar.Maximum = Convert.ToInt32(player.Duration.TotalSeconds); }); if (!positioncchangedevent) { player.PositionChanged += PositionChanged; positioncchangedevent = true; } } else { cmbLangs.Invoke((System.Threading.ThreadStart) delegate { cmbLangs.Enabled = false; cmbLangs.Items.Clear(); }); cmbSubs.Invoke((System.Threading.ThreadStart) delegate { cmbSubs.Enabled = false; cmbSubs.Items.Clear(); }); seekBar.Invoke((System.Threading.ThreadStart) delegate { seekBar.Enabled = false; seekBar.Value = 0; }); } player.Resume(); btnPlayPause.BackgroundImage = Image.FromFile("./resources/images/pause.png"); btnPlayPause.BackgroundImageLayout = ImageLayout.Stretch; }
private void MediaLoaded(object sender, EventArgs e) { ParseTracksAndSetDefaults(); if (!isChannel && player.Duration.TotalSeconds > 0) { seekBar.Invoke((System.Threading.ThreadStart) delegate { seekBar.Enabled = true; seekBar.Value = 0; seekBar.Maximum = Convert.ToInt32(player.Duration.TotalSeconds); if (SetPositionOnLoad) { seekBar.Value = positionOnLoad; } }); if (!positioncchangedevent) { player.PositionChanged += PositionChanged; positioncchangedevent = true; } } /*else * { * cmbLangs.Invoke((System.Threading.ThreadStart)delegate * { * cmbLangs.Enabled = false; * cmbLangs.Items.Clear(); * }); * cmbSubs.Invoke((System.Threading.ThreadStart)delegate * { * cmbSubs.Enabled = false; * cmbSubs.Items.Clear(); * * }); * seekBar.Invoke((System.Threading.ThreadStart)delegate { * seekBar.Enabled = false; * seekBar.Value = 0; * }); * }*/ player.Resume(); if (SetPositionOnLoad) { player.SeekAsync(positionOnLoad); SetPositionOnLoad = false; } btnPlayPause.BackgroundImage = Image.FromFile("./resources/images/pause.png"); btnPlayPause.BackgroundImageLayout = ImageLayout.Stretch; if (currLang > -1) { cmbLangs.Invoke((System.Threading.ThreadStart) delegate { cmbLangs.SelectedIndex = currLang; }); currLang = -1; } if (currSub > -1) { cmbSubs.Invoke((System.Threading.ThreadStart) delegate { cmbSubs.SelectedIndex = currSub; }); currSub = -1; } panelvideo.Invoke((System.Threading.ThreadStart) delegate { panelvideo.Focus(); }); }
private void MediaLoaded(object sender, EventArgs e) { if (AmiConfiguration.Get().ENABLE_LOG) { string msg = "[MediaLoaded-MPV] MPV load streaming with next values: "; msg += $"SetPositionOnLoad => {SetPositionOnLoad} "; msg += $"currLang => {currLang} "; msg += $"isChannel=> {isChannel} "; msg += $"positioncchangedevent=> {positioncchangedevent} "; msg += $"player.Duration.TotalSeconds=> {player.Duration.TotalSeconds} "; Logger.Current.Debug(msg); } ParseTracksAndSetDefaults(); if (!isChannel && player.Duration.TotalSeconds > 0) { seekBar.Invoke((System.Threading.ThreadStart) delegate { seekBar.Enabled = true; seekBar.Value = 0; seekBar.Maximum = Convert.ToInt32(player.Duration.TotalSeconds); if (SetPositionOnLoad) { seekBar.Value = positionOnLoad; } }); if (!positioncchangedevent) { player.PositionChanged += PositionChanged; positioncchangedevent = true; } } /*else * { * cmbLangs.Invoke((System.Threading.ThreadStart)delegate * { * cmbLangs.Enabled = false; * cmbLangs.Items.Clear(); * }); * cmbSubs.Invoke((System.Threading.ThreadStart)delegate * { * cmbSubs.Enabled = false; * cmbSubs.Items.Clear(); * * }); * seekBar.Invoke((System.Threading.ThreadStart)delegate { * seekBar.Enabled = false; * seekBar.Value = 0; * }); * }*/ player.Resume(); if (SetPositionOnLoad) { player.SeekAsync(positionOnLoad); SetPositionOnLoad = false; } btnPlayPause.BackgroundImage = Image.FromFile("./resources/images/pause.png"); btnPlayPause.BackgroundImageLayout = ImageLayout.Stretch; if (currLang > -1) { cmbLangs.Invoke((System.Threading.ThreadStart) delegate { cmbLangs.SelectedIndex = currLang; }); currLang = -1; } if (currSub > -1) { cmbSubs.Invoke((System.Threading.ThreadStart) delegate { cmbSubs.SelectedIndex = currSub; }); currSub = -1; } panelvideo.Invoke((System.Threading.ThreadStart) delegate { panelvideo.Focus(); }); }
private void ButtonPlayOnClick(object sender, RoutedEventArgs e) { player.Resume(); }