Click here to Skip to main content
13,554,469 members
Click here to Skip to main content

Stats

641.1K views
28.4K downloads
270 bookmarked
Posted 14 Sep 2010
Licenced CPOL

PVS.AVPlayer - MCI Audio and Video Library

, 16 Apr 2018
Windows Media Control Interface (MCI) library with many added features
PVS.AVPlayer
PVS.AVPlayer .NET 2.0
PVS.AVPlayer .NET 3.0
PVS.AVPlayer .NET 3.5
PVS.AVPlayer .NET 4.0
PVS.AVPlayer .NET 4.5
PVS.AVPlayer .NET 4.5.1
PVS.AVPlayer .NET 4.5.2
PVS.AVPlayer .NET 4.6
PVS.AVPlayer.dll
PVS.AVPlayer.dll
PVS.AVPlayer.dll
PVS.AVPlayer.dll
PVS.AVPlayer.dll
PVS.AVPlayer.dll
PVS.AVPlayer.dll
PVS.AVPlayer .NET 4.6.1
PVS.AVPlayer.dll
PVS.AVPlayer .NET 4.6.2
PVS.AVPlayer.dll
PVS.AVPlayer.dll
PVS.AVPlayer .NET 4.7
PVS.AVPlayer .NET 4.7.1
PVS.AVPlayer.dll
PVS.AVPlayer .NET 4.7.2
PVS.AVPlayer.dll
PVS.AVPlayer.dll
PVS.AVPlayer All Source Code
AVPlayerExample
AVPlayerExample
AVPlayerExample.csproj.user
bin
Debug
Release
Dialogs
Display Overlays
obj
Debug
Release
x86
Debug
Release
Properties
Resources
Crystal Italic1.ttf
WingDings3a.ttf
Voice Recorder
FolderView
FolderView
bin
Debug
Release
FolderView.csproj.user
obj
Release
x86
Debug
Release
Properties
Resources
Crystal Italic1.ttf
PVS.AVPlayer
AVPlayerExample.csproj.user
PVS.AVPlayer.dll
Custom Items
Native Methods
Bob.png
Crystal Italic1.ttf
Dial Green 2.png
Dial Green 4.png
Dial Green.png
Dial Red 2.png
Dial Red.png
media7.ico
media7a.ico
Media8.ico
Media8a.ico
VU Meter.png
WingDings3a.ttf
Sound Recorder
Various
About Dialog
PVS.AVPlayer.dll
Custom Items
FolderView.csproj.user
Bob.png
Crystal Italic1.ttf
media7a.ico
media7b.ico
Media8a.ico
Media8b.ico
Subtitles Overlay
Various
How To (C#)
PVSAVPlayerHowTo
bin
Debug
PVS.AVPlayer.dll
Release
Properties
How To (VB.NET)
PVSAVPlayerHowToVB
ApplicationEvents.v_b
bin
Debug
PVS.AVPlayer.dll
Release
Form1.Designer.v_b
Form1.v_b
My Project
app.manifest
Application.Designer.v_b
Application.myapp
AssemblyInfo.v_b
Resources.Designer.v_b
Settings.Designer.v_b
Overlay.Designer.v_b
Overlay.v_b
PVSAVPlayerHowTo.vbproj.user
PVS.AVPlayer Examples
AVPlayerExample.ex_
FolderView.ex_
AVPlayerExample.exe
FolderView.exe
PVS.AVPlayer.dll
#region Usings

using PVS.AVPlayer;
using System;
using System.Drawing;
using System.IO;
using System.Windows.Forms;

#endregion

namespace AVPlayerExample
{
    public partial class PIPOverlay : Form, IOverlay
    {
        /*
        
        PVS.AVPlayer Display Overlay - Example 'PIP'
        Displays a Picture-In-Picture (movie) player.
        
        */

        // ******************************** Fields

        #region Fields

        private const string    OVERLAY_NAME = "PIP Overlay";
        private const int       NO_ERROR = 0;

        private Form1   _baseForm;

        private Player  _pipPlayer1;
        private bool    _autoPaused;

        private bool    _pipPanelVisible;
        private bool    _pipControlsEnabled = true;
        private bool    _movingEnabled = true;
        private bool    _resizingEnabled = true;

        private bool    _playMenuRightButton;
        private Point   _playMenuPopUpLocation;
        private int     _playMenuItemIndex;

        private int     _mediaToPlay;

        // Used with PIP Moving and Sizing
        private bool    _pipSizing;
        private int     _pipSizingType;
        private Point   _oldMouseSizePos;
        private Point   _newMouseSizePos;

        private bool    _disposed;

        #endregion

        // ******************************** Main

        #region Main

        public PIPOverlay(Form1 baseForm)
        {
            InitializeComponent();

            _baseForm = baseForm;
            _pipPlayer1 = new Player(displayPanel)
            {
                DisplayMode = DisplayMode.Stretch,
                AudioEnabled = false,
                PositionSlider = positionSlider
            };

            // Pass on drag and drop to main form (handled in source file: DragDrop.cs):
            AllowDrop = true;
            //DragEnter += _baseForm.Form1_DragEnter;
            DragDrop += _baseForm.Form1_DragDrop;

            // Construct displayContextmenu - add playMenu as dropdown
            ((ToolStripMenuItem)displayMenu.Items[0]).DropDown = playMenu;
            ReBuildPIPPlayListMenu();
        }

        private void PIPOverlay_VisibleChanged(object sender, EventArgs e)
        {
            if (Visible)
            {
                if (_autoPaused)
                {
                    _pipPlayer1.Resume();
                    _autoPaused = false;
                }
                _pipPlayer1.PositionSliderLiveUpdate = _baseForm.Player1.PositionSliderLiveUpdate;
            }
            else
            {
                if (!_pipPlayer1.Paused)
                {
                    _pipPlayer1.Pause();
                    _autoPaused = true;
                }
            }
        }

        // Keep the PiP inside the overlay
        private void PIPOverlay_Resize(object sender, EventArgs e)
        {
            if (pipPanel.Left < 0) pipPanel.Left = 0;
            else
            {
                if (pipPanel.Left > Width) pipPanel.Left = Width - pipPanel.Width;
                if (pipPanel.Left < 0) pipPanel.Left = 0;
            }
            if (pipPanel.Top < 0) pipPanel.Top = 0;
            else
            {
                if (pipPanel.Top > Height) pipPanel.Top = Height - pipPanel.Height;
                if (pipPanel.Top < 0) pipPanel.Top = 0;
            }

            if (pipPanel.Left + pipPanel.Width > Width)
            {
                pipPanel.Width = Width - pipPanel.Left;
                if (pipPanel.Left + pipPanel.Width > Width)
                {
                    pipPanel.Left = Width - pipPanel.Width;
                    if (pipPanel.Left < 0) pipPanel.Left = 0;
                }
            }
            if (pipPanel.Top + pipPanel.Height > Height)
            {
                pipPanel.Height = Height - pipPanel.Top;
                if (pipPanel.Left + pipPanel.Height > Height)
                {
                    pipPanel.Top = Height - pipPanel.Height;
                    if (pipPanel.Top < 0) pipPanel.Top = 0;
                }
            }
        }

        /// <summary>
        /// Clean up any resources being used.
        /// </summary>
        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
        protected override void Dispose(bool disposing)
        {
            if (!_disposed)
            {
                if (disposing)
                {
                    DragEnter -= _baseForm.Form1_DragEnter;
                    DragDrop -= _baseForm.Form1_DragDrop;

                    _pipPlayer1.Dispose(); _pipPlayer1 = null;
                    _baseForm = null;

                    if (components != null) components.Dispose();
                }
                base.Dispose(disposing);
                _disposed = true;
            }
        }

        #endregion

        // ******************************** IOverlay Control

        #region IOverlay Control

        // The visibility of the menu is controlled by the user from the main application (in this example application)
        public bool HasMenu
        {
            get { return false; }
        }

        public bool MenuEnabled
        {
            get { return false; }
            set { }
        }

        public void MediaStopped()
        {
            // not used with this overlay
        }

        #endregion

        // ******************************** Player PlayMedia / PlayNextMedia

        #region Player PlayMedia / PlayNextMedia

        // Play a mediafile
        private void PlayMedia(string fileName)
        {
            if (_pipPlayer1.Play(fileName) != NO_ERROR)
            {
                // Show error message
                MessageBox.Show(
                    caption: OVERLAY_NAME,
                    icon: MessageBoxIcon.Exclamation,
                    text: fileName + "\r\n\r\n" + _pipPlayer1.LastErrorString,
                    buttons: MessageBoxButtons.OK,
                    owner: this);

                // Continue playing next mediafile
                if (Form1.Prefs.OnErrorPlayNext && _baseForm.PlayList.Count > 1) PlayNextMedia();
            }
        }

        // Play a mediafile and update the 'next' counter
        private void PlayNextMedia()
        {
            if (_baseForm.PlayList.Count > 0)
            {
                if (_mediaToPlay >= _baseForm.PlayList.Count) _mediaToPlay = 0;
                PlayMedia(_baseForm.PlayList[_mediaToPlay++]);
            }
        }

        #endregion

        // ******************************** PIP Controls Visibility

        #region PIP Controls Visibility

        private void displayPanel_MouseEnter(object sender, EventArgs e)
        {
            if (_pipSizing || !_pipControlsEnabled) return;
            ShowPIPPanel();
        }

        private void pipPanel_MouseLeave(object sender, EventArgs e)
        {
            if (_pipSizing) return;
            if (!pipPanel.ClientRectangle.Contains(pipPanel.PointToClient(Cursor.Position))) HidePIPPanel();
        }

        private void ShowPIPPanel()
        {
            if (!_pipPanelVisible && _pipControlsEnabled)
            {
                playButton.Show();
                pauseButton.Show();
                stopButton.Show();
                positionSlider.Show();
                _pipPanelVisible = true;
            }
        }

        private void HidePIPPanel()
        {
            if (_pipPanelVisible)
            {
                playButton.Hide();
                pauseButton.Hide();
                stopButton.Hide();
                positionSlider.Hide();
                _pipPanelVisible = false;
            }
        }

        #endregion

        // ******************************** PIP Moving and Sizing

        #region PIP Moving and Sizing

        private void sizePanelSizing_MouseDown(object sender, MouseEventArgs e)
        {
            _oldMouseSizePos = ((Panel)sender).PointToScreen(e.Location);
            HidePIPPanel();
            if (sender == sizePanelWE) _pipSizingType = 0;
            else if (sender == sizePanelNS) _pipSizingType = 1;
            else if (sender == sizePanelNWSE) _pipSizingType = 2;
            else _pipSizingType = 3; // Move
            _pipSizing = true;
        }

        private void sizePanelSizing_MouseMove(object sender, MouseEventArgs e)
        {
            Point newPosition = pipPanel.Location;
            Size newSize = pipPanel.Size;

            if (!_pipSizing) return;
            _newMouseSizePos = ((Panel)sender).PointToScreen(e.Location);

            switch (_pipSizingType)
            {
                case 3:
                    if (_newMouseSizePos.Y != _oldMouseSizePos.Y)
                    {
                        newPosition.Y = pipPanel.Top + (_newMouseSizePos.Y - _oldMouseSizePos.Y);
                        if (pipPanel.Top < 0) newPosition.Y = 0;
                        else
                        {
                            if (_pipControlsEnabled)
                            {
                                if (newPosition.Y + pipPanel.Height > Height) newPosition.Y = Height - pipPanel.Height;
                            }
                            else
                            {
                                // 45 is about the height of the control buttons + slider
                                if (newPosition.Y + (pipPanel.Height - 45)  > Height) newPosition.Y = Height - (pipPanel.Height - 45);
                            }
                        }
                    }
                    if (_newMouseSizePos.X != _oldMouseSizePos.X)
                    {
                        newPosition.X = pipPanel.Left + (_newMouseSizePos.X - _oldMouseSizePos.X);
                        if (pipPanel.Left < 0) newPosition.X = 0;
                        else if (newPosition.X + pipPanel.Width > Width) newPosition.X = Width - pipPanel.Width;
                    }
                    pipPanel.Location = newPosition;
                    break;
                case 0:
                    if (_newMouseSizePos.X != _oldMouseSizePos.X)
                    {
                        newSize.Width = pipPanel.Width + (_newMouseSizePos.X - _oldMouseSizePos.X);
                        if (newPosition.X + newSize.Width > Width) newSize.Width = Width - newPosition.X;
                        pipPanel.Width = newSize.Width;
                    }
                    break;
                default:
                    if (_newMouseSizePos.Y != _oldMouseSizePos.Y)
                    {
                        newSize.Height = pipPanel.Height + (_newMouseSizePos.Y - _oldMouseSizePos.Y);
                        if (_pipControlsEnabled)
                        {
                            if (newPosition.Y + newSize.Height > Height) newSize.Height = Height - newPosition.Y;
                        }
                        else if (newPosition.Y + (newSize.Height - 45) > Height) newSize.Height = Height - (newPosition.Y - 45);
                        pipPanel.Height = newSize.Height;
                    }
                    if (_pipSizingType == 2 && _newMouseSizePos.X != _oldMouseSizePos.X)
                    {
                        newSize.Width = pipPanel.Width + (_newMouseSizePos.X - _oldMouseSizePos.X);
                        if (newPosition.X + newSize.Width > Width) newSize.Width = Width - newPosition.X;
                        pipPanel.Width = newSize.Width;
                    }
                    break;
            }
            _oldMouseSizePos = _newMouseSizePos;
        }

        private void sizePanelSizing_MouseUp(object sender, MouseEventArgs e)
        {
            _pipSizing = false;
        }

        #endregion

        // ******************************** Play, Pause/Resume and Stop Button

        #region Play Button

        private void playMenu_MouseClick(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Right)
            {
                _playMenuRightButton = true;
                _playMenuPopUpLocation.X = e.Location.X - 1;
                _playMenuPopUpLocation.Y = e.Location.Y - 1;
            }
        }

        private void playMenu_ItemClicked(object sender, ToolStripItemClickedEventArgs e)
        {
            _playMenuItemIndex = playMenu.Items.IndexOf(e.ClickedItem);

            if (_playMenuItemIndex == 0) // This is menu item 'Add MediaFiles'
            {
                playMenu.Close();
                if (displayMenu.Visible) displayMenu.Close();
                HidePIPPanel();
                SelectMediaFiles();
            }
            else
            {
                if (_playMenuRightButton)
                {
                    _playMenuRightButton = false;
                    playMenu.AutoClose = false;
                    if (displayMenu.Visible) displayMenu.AutoClose = false;
                    playMenu.Items[_playMenuItemIndex].BackColor = SystemColors.GradientInactiveCaption;
                    playSubMenu.Show(playMenu.PointToScreen(_playMenuPopUpLocation));
                }
                else
                {
                    playMenu.Close();
                    if (displayMenu.Visible) displayMenu.Close();
                    HidePIPPanel();
                    _mediaToPlay = _playMenuItemIndex - 2;
                    PlayNextMedia();
                }
            }
        }

        private void playSubMenu_ItemClicked(object sender, ToolStripItemClickedEventArgs e)
        {
            playSubMenu.Close();
            playMenu.AutoClose = true;
            displayMenu.AutoClose = true;
            switch (playSubMenu.Items.IndexOf(e.ClickedItem))
            {
                case 0: // Play the mediafile
                    playMenu.Close();
                    if (displayMenu.Visible) displayMenu.Close();
                    HidePIPPanel();
                    _mediaToPlay = _playMenuItemIndex - 2;
                    PlayNextMedia();
                    break;

                case 1: // Remove from List
                    _baseForm.PlayList.RemoveAt(_playMenuItemIndex - 2);
                    _playMenuItemIndex--;
                    //baseForm.ReBuildPlayListMenu();
                    SavePlayList();
                    // Rebuild my menu
                    ReBuildPIPPlayListMenu();
                    break;

                case 3: // Sort List
                    _baseForm.PlayList.Sort();
                    //baseForm.ReBuildPlayListMenu();
                    SavePlayList();
                    // Rebuild my menu
                    ReBuildPIPPlayListMenu();
                    break;
            }
        }

        #endregion

        #region PlayMenu Drag and Drop

        private bool        _ddMouseDown;
        private bool        _ddOurDrag;
        private int         _ddSourceIndex;
        private Point       _ddMouseLocation;
        ToolStripMenuItem   _ddDragMenuItem;

        private void PlayMenu_MouseDown(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Left)
            {
                _ddMouseLocation = e.Location;
                _ddDragMenuItem = (ToolStripMenuItem)sender;
                _ddDragMenuItem.MouseMove += PlayMenu_MouseMove;
                _ddDragMenuItem.MouseUp += PlayMenu_MouseUp;
                _ddSourceIndex = playMenu.Items.IndexOf((ToolStripMenuItem)sender);
                _ddMouseDown = true;
            }
        }

        private void PlayMenu_MouseMove(object sender, MouseEventArgs e)
        {
            if (_ddMouseDown && (Math.Abs(_ddMouseLocation.X - e.Location.X) > 3 || Math.Abs(_ddMouseLocation.Y - e.Location.Y) > 3))
            {
                _ddMouseDown = false; // we don't get a mouse up event after dodragdrop

                _ddDragMenuItem.MouseMove -= PlayMenu_MouseMove;
                _ddDragMenuItem.MouseUp -= PlayMenu_MouseUp;

                _ddOurDrag = true;
                playMenu.DoDragDrop(_baseForm.PlayList[_ddSourceIndex - 2], DragDropEffects.Move);
                _ddOurDrag = false;
            }
        }

        private void PlayMenu_MouseUp(object sender, MouseEventArgs e)
        {
            _ddDragMenuItem.MouseMove -= PlayMenu_MouseMove;
            _ddDragMenuItem.MouseUp -= PlayMenu_MouseUp;
            _ddMouseDown = false;
        }

        // DragEnter not needed - responding only to 'our drag'
        private void playMenu_DragOver(object sender, DragEventArgs e)
        {
            if (_ddOurDrag)
            {
                Point location = playMenu.PointToClient(new Point(e.X, e.Y));
                e.Effect = playMenu.Items.IndexOf(playMenu.GetItemAt(location)) > 1 ? DragDropEffects.Move : DragDropEffects.None;
            }
            else e.Effect = DragDropEffects.None;
        }

        private void PlayMenu_DragDrop(object sender, DragEventArgs e)
        {
            if (_ddOurDrag)
            {
                Point location = playMenu.PointToClient(new Point(e.X, e.Y));
                int ddDestIndex = playMenu.Items.IndexOf(playMenu.GetItemAt(location));
                if (ddDestIndex != _ddSourceIndex && ddDestIndex > 1)
                {
                    ToolStripMenuItem menuItem = (ToolStripMenuItem)playMenu.Items[_ddSourceIndex];
                    playMenu.Items.RemoveAt(_ddSourceIndex);
                    playMenu.Items.Insert(ddDestIndex, menuItem);

                    string listItem = _baseForm.PlayList[_ddSourceIndex - 2];
                    _baseForm.PlayList.RemoveAt(_ddSourceIndex - 2);
                    _baseForm.PlayList.Insert(ddDestIndex - 2, listItem);

                    SavePlayList();
                }
            }
        }

        #endregion

        #region Pause Button

        private void pauseButton_Click(object sender, EventArgs e)
        {
            _pipPlayer1.Paused = !_pipPlayer1.Paused;
            if (_pipPlayer1.Paused) displayMenu.Items[1].Text = pauseButton.Text = "Resume";
            else displayMenu.Items[1].Text = pauseButton.Text = "Pause";
        }

        #endregion

        #region Stop Button

        private void stopButton_Click(object sender, EventArgs e)
        {
            _pipPlayer1.Stop();
        }

        #endregion

        // ******************************** Select Mediafiles

        #region Select Mediafiles

        // Use an OpenFileDialog to select mediafiles and add them to the PlayList - using the baseForm Form1
        private void SelectMediaFiles()
        {
            _baseForm.OpenFileDialog1.Title = Form1.OPENMEDIA_DIALOG_TITLE;
            _baseForm.OpenFileDialog1.Filter = string.Empty;
            _baseForm.OpenFileDialog1.InitialDirectory = Form1.Prefs.MediaFilesFolder;
            _baseForm.OpenFileDialog1.Multiselect = true;

            if (_baseForm.OpenFileDialog1.ShowDialog(this) == DialogResult.OK)
            {
                //_baseForm.MediaDirectory = Path.GetDirectoryName(_baseForm.OpenFileDialog1.FileName);

                int newToPlay = _baseForm.PlayList.Count;
                _baseForm.AddToPlayList(_baseForm.OpenFileDialog1.FileNames);
                ReBuildPIPPlayListMenu();
                if (!_pipPlayer1.Playing)
                {
                    _mediaToPlay = newToPlay;
                    PlayNextMedia();
                }
            }
        }

        #endregion

        // ******************************** Rebuild playMenu

        #region Rebuild playMenu and SavePlayList

        internal void ReBuildPIPPlayListMenu()
        {
            playMenu.SuspendLayout();
            while (playMenu.Items.Count > 2) playMenu.Items.RemoveAt(2);
            for (int i = 0; i < _baseForm.PlayList.Count; i++)
            {
                // should omit non-video files...
                playMenu.Items.Add(Path.GetFileName(_baseForm.PlayList[i].Replace("&", "&&")));
                if (_baseForm.PlayList[i].StartsWith("http:", StringComparison.OrdinalIgnoreCase)) playMenu.Items[i + 2].ForeColor = Color.Gold;
                playMenu.Items[i + 2].MouseDown += PlayMenu_MouseDown;
            }
            playMenu.ResumeLayout();
        }

        // Save the PlayList to disk (used when the PlayList has changed)
        private void SavePlayList()
        {
            try
            {
                if (_baseForm.PlayList.Count > 0) File.WriteAllLines(_baseForm.PlayListFile, _baseForm.PlayList.ToArray());
                else if (File.Exists(_baseForm.PlayListFile)) File.Delete(_baseForm.PlayListFile);
                _baseForm.ReBuildPlayListMenu(); // update main form playmenu
            }
            catch { }
        }

        #endregion

        // ******************************** Display ContextMenu

        #region Display ContextMenu

        private void pauseMenuItem_Click(object sender, EventArgs e)
        {
            pauseButton_Click(this, EventArgs.Empty);
            HidePIPPanel();
        }

        private void stopMenuItem_Click(object sender, EventArgs e)
        {
            _pipPlayer1.Stop();
            HidePIPPanel();
        }

        private void enableControlsMenuItem_Click(object sender, EventArgs e)
        {
            _pipControlsEnabled = !_pipControlsEnabled;
            enableControlsMenuItem.Checked = _pipControlsEnabled;
            if (!_pipControlsEnabled) HidePIPPanel();
            else ShowPIPPanel();
        }

        private void enableMovingMenuItem_Click(object sender, EventArgs e)
        {
            _movingEnabled = !_movingEnabled;
            sizePanelMove.Enabled = _movingEnabled;
            enableMovingMenuItem.Checked = _movingEnabled;
            HidePIPPanel();
        }

        private void enableResizingMenuItem_Click(object sender, EventArgs e)
        {
            _resizingEnabled = !_resizingEnabled;
            sizePanelNS.Enabled = _resizingEnabled;
            sizePanelWE.Enabled = _resizingEnabled;
            sizePanelNWSE.Enabled = _resizingEnabled;
            enableResizingMenuItem.Checked = _resizingEnabled;
            HidePIPPanel();
        }

        // Opacity
        private void HandleToolStripOpacity(object sender, EventArgs e)
        {
            double value;

            // get the text of the menu item (e.g. 50%), remove the '%' and convert to double value
            if (double.TryParse(((ToolStripMenuItem)sender).Text.TrimEnd('%'), out value))
            {
                if (value >= 25 && value <= 100)
                {
                    Opacity = value / 100;

                    // Removes the check marks from the Opacity contextmenu items and checks the selected item
                    foreach (ToolStripItem item in (((ToolStripMenuItem)sender).GetCurrentParent().Items))
                    {
                        if (item.GetType() == typeof(ToolStripMenuItem))
                        {
                            ((ToolStripMenuItem)item).Checked = item == sender;
                        }
                    }
                }
            }
            HidePIPPanel();
        }

        // Switch base player and pipplayer screens
        private void switchScreensMenuItem_Click(object sender, EventArgs e)
        {
            // Because one of the displays is on an overlay of the other display, don't just switch the player's displays.

            // base player
            string movie1 = _baseForm.Player1.GetMediaName(MediaName.FullPath);
            TimeSpan position1 = _baseForm.Player1.Position;
            bool playing1 = _baseForm.Player1.Playing;
            bool paused1 = _baseForm.Player1.Paused;

            // pip player
            string movie2 = _pipPlayer1.GetMediaName(MediaName.FullPath);
            TimeSpan position2 = _pipPlayer1.Position;
            bool playing2 = _pipPlayer1.Playing;
            bool paused2 = _pipPlayer1.Paused;

            // Reducing screen flahing (by not closing and reopening the overlay):
            bool holdCopy = _baseForm.Player1.OverlayHold;
            _baseForm.Player1.OverlayHold = true;
            _baseForm.StopAndPlay = true;

            if (playing2)
            {
                _baseForm.Player1.Paused = paused2;
                _baseForm.Player1.Play(movie2);
                _baseForm.Player1.Position = position2;
            }

            if (playing1)
            {
                _pipPlayer1.Paused = paused1; // may be overridden by autoPaused (PIPOverlay_VisibleChanged), so:
                if (paused1) _autoPaused = false;
                _pipPlayer1.Play(movie1);
                _pipPlayer1.Position = position1;
            }
            else _pipPlayer1.Stop();

            _baseForm.Player1.OverlayHold = holdCopy;
        }

        #endregion
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Peter Vegter
United States United States
No Biography provided

You may also be interested in...

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web04-2016 | 2.8.180515.1 | Last Updated 16 Apr 2018
Article Copyright 2010 by Peter Vegter
Everything else Copyright © CodeProject, 1999-2018
Layout: fixed | fluid