public RenderForm() { BackColor = Color.Magenta; TransparencyKey = Color.Magenta; InitializeComponent(); FormBorderStyle = FormBorderStyle.None; string appDir = System.IO.Path.GetDirectoryName(Assembly.GetEntryAssembly().Location); player = new MpvPlayer(this.Handle, $@"{appDir}\lib\mpv-1.dll") { Loop = true, Volume = 0 }; //var test = player.API.GetPropertyString("video-aspect"); //player.API.SetPropertyString("video-aspect", "1:1"); FormClosing += RenderForm_FormClosing; //处理alt+tab可以看见本程序 //https://stackoverflow.com/questions/357076/best-way-to-hide-a-window-from-the-alt-tab-program-switcher //int exStyle = (int)GetWindowLong(this.Handle, (int)GetWindowLongFields.GWL_EXSTYLE); //exStyle |= (int)ExtendedWindowStyles.WS_EX_TOOLWINDOW; //SetWindowLong(this.Handle, (int)GetWindowLongFields.GWL_EXSTYLE, (IntPtr)exStyle); }
public MPVPlayer() { InitializeComponent(); player = new MpvPlayer(panelvideo.Handle); originalSizePanel = panelvideo.Bounds; originalSizeWin = this.Bounds; originalPositionWin = new Tuple <int, int>(this.Top, this.Left); ReloadLang(); }
//private bool ValidateTest { get { return Title.} } public EditorWindow() { InitializeComponent(); this.DataContext = this; player = new MpvPlayer(VideoPlayer.Handle) { Loop = true, Volume = 0, }; controller = Controller.getInstance(); }
// TODO Check why this is claiming that it's functioning on a different thread yet no thread is made when calling this? Finding this out will determine if the Invokes remain public WallpaperForm(Screen monitor, IntPtr workerw) { this.SetStyle(ControlStyles.SupportsTransparentBackColor, true); InitializeComponent(); Load += (s, e) => { this.Invoke((MethodInvoker) delegate { BackColor = Color.Black; // Sets bounds of the form Width = monitor.Bounds.Width; Height = monitor.Bounds.Height; Left = monitor.Bounds.X + DisplayData.DisplayXAdjustment; Top = monitor.Bounds.Y + DisplayData.MinDisplayY; pictureBoxBounds = new Rectangle(0, 0, Width, Height); // Sets bounds of the wallpaper pictureBoxWallpaper.Bounds = pictureBoxBounds; panelWallpaper.Bounds = pictureBoxBounds; // Initializes player player = new MpvPlayer(panelWallpaper.Handle) // handle tells the player to draw itself onto the panelWallpaper { AutoPlay = true, Loop = true }; player.MediaEndedSeeking += (sender, args) => Loops++; ResetWallpaperStyle(); // This line makes the form a child of the WorkerW window, thus putting it behind the desktop icons and out of reach // for any user input. The form will just be rendered, no keyboard or mouse input will reach it. // (Would have to use WH_KEYBOARD_LL and WH_MOUSE_LL hooks to capture mouse and keyboard input) Win32.SetParent(Handle, workerw); }); }; Closing += (s, e) => { Controls.Remove(pictureBoxWallpaper); player.Stop(); /*! //the below caused an assertion failed error * await Task.Delay(1000).ConfigureAwait(false); * player.Dispose(); */ Controls.Remove(panelWallpaper); }; }
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 Form1() { InitializeComponent(); originalSizePanel = panelvideo.Bounds; originalSizeWin = this.Bounds; originalPositionWin = new Tuple <int, int>(this.Top, this.Left); player = new MpvPlayer(panelvideo.Handle); chList.View = View.Details; logoEPG.WaitOnLoad = false; logoChannel.WaitOnLoad = false; _instance = this; }
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 SetupPlayer() { player = new MpvPlayer("lib\\mpv-1.dll") { AutoPlay = true }; playerHost.Children.Add(player); player.MediaLoaded += PlayerOnMediaLoaded; player.MediaUnloaded += PlayerOnMediaUnloaded; player.PositionChanged += PlayerOnPositionChanged; player.EnableYouTubeDl(@"scripts\ytdl_hook.lua"); player.YouTubeDlVideoQuality = YouTubeDlVideoQuality.MediumHigh; player.Load(@"https://www.youtube.com/watch?v=E5ln4uR4TwQ"); player.Load(@"https://www.youtube.com/watch?v=SNoK5pyK73c"); }
public Form1(string platform, string id) { this.platform = platform; this.id = id; InitializeComponent(); player = new MpvPlayer(Handle) { Volume = 50, }; player.MediaFinished += (s, e) => Close(); player.MediaError += (s, e) => Close(); Load += Form1_Load; FormClosing += Form1_FormClosing; MouseDown += Form1_MouseDown; MouseWheel += ChangeVolume; KeyDown += Form1_KeyDown; }
private void RenderWindow_Loaded(object sender, RoutedEventArgs e) { //处理alt+tab可以看见本程序 //https://stackoverflow.com/questions/357076/best-way-to-hide-a-window-from-the-alt-tab-program-switcher WindowInteropHelper wndHelper = new WindowInteropHelper(this); int exStyle = (int)GetWindowLong(wndHelper.Handle, (int)GetWindowLongFields.GWL_EXSTYLE); exStyle |= (int)ExtendedWindowStyles.WS_EX_TOOLWINDOW; SetWindowLong(wndHelper.Handle, (int)GetWindowLongFields.GWL_EXSTYLE, (IntPtr)exStyle); Loaded -= RenderWindow_Loaded; double width = Screen.AllScreens[0].Bounds.Width; double height = Screen.AllScreens[0].Bounds.Height; Width = width; Height = height; ////Top = -4; ////Left = 0; //WindowState = WindowState.Maximized; //WindowStartupLocation = WindowStartupLocation.Manual; //Top = 0; //Left = 0; string appDir = System.IO.Path.GetDirectoryName(Assembly.GetEntryAssembly().Location); player = new MpvPlayer(PlayerHost.Handle, $@"{appDir}\lib\mpv-1.dll") { Loop = true, Volume = 0 }; ReloadWallpaper(); }
private void RenderForm_FormClosing(object sender, FormClosingEventArgs e) { FormClosing -= RenderForm_FormClosing; Player?.Dispose(); Player = null; }
public void LinkPlayer(MpvPlayer player, Action updater) { this.mpvPlayer = player; this.updater = updater; //?timerVideo.Start(); //? placing this in the constructor will cause timerVideo to activate on design time, causing a crash | Auto-enabled by control now, oops }
public MainWindow() { InitializeComponent(); //DataContext = viewModel; viewModel = (MainViewModel)DataContext; airWindow.DataContext = viewModel; OverrideLanguage(); settings = Settings.Read(); if (settings.Maximized) { WindowState = WindowState.Maximized; } player = CreatePlayer(); project = RestoreBackup(settings); if (settings.SafelyExited) { settings.SafelyExited = false; settings.Write(); } Title = GetTitle(project, listView.SelectedIndex); InitTimeline(timeline); LoadSubtitles(project, timeline); LoadRefSubtitles(project, timeline); playerGrid.Children.Remove(overlayGrid); airWindow.contentGrid.Children.Add(overlayGrid); bakTimer.Tick += BakTimer_Tick; bakTimer.Start(); MpvPlayer CreatePlayer() { var player = new MpvPlayer(playerHost.Handle) { Loop = true, Volume = 100 }; player.API.SetPropertyString("sid", "no"); //disable subtitles player.API.SetPropertyString("keep-open", "yes"); player.PositionChanged += Player_PositionChanged; player.MediaFinished += Player_MediaFinished; player.MediaLoaded += Player_MediaLoaded; return(player); } void InitTimeline(Timeline timeline) { var itemContextMenu = (ContextMenu)FindResource("ItemContextMenu"); var insertContextMenu = (ContextMenu)FindResource("InsertContextMenu"); timeline.NeedleMoved += Timeline_NeedleMoved; timeline.SelectedItems.CollectionChanged += Timeline_SelectedItems_CollectionChanged; timeline.ChunkContextMenu = itemContextMenu; timeline.ContextMenu = insertContextMenu; var refTrack = new Track(timeline, true) { Height = 50, Name = "", }; var editTrack = new Track(timeline, false) { Name = "", }; timeline.Tracks.Add(refTrack); timeline.Tracks.Add(editTrack); editTrack.ChunkContextMenuOpening += Track_ChunkContextMenuOpening; } void OverrideLanguage() { //use OS culture for bindings LanguageProperty.OverrideMetadata( typeof(FrameworkElement), new FrameworkPropertyMetadata( XmlLanguage.GetLanguage(CultureInfo.CurrentCulture.IetfLanguageTag) ) ); } }