Click here to Skip to main content
13,630,649 members
Click here to Skip to main content

Stats

664.6K views
29.1K downloads
274 bookmarked
Posted 14 Sep 2010
Licenced CPOL

PVS.AVPlayer - MCI Audio and Video Library

, 1 Jun 2018
Windows Media Control Interface (MCI) library with many added features
PVS.AVPlayer
PVS.AVPlayer .NET 2.0
PVS.AVPlayer.XML
PVS.AVPlayer .NET 3.0
PVS.AVPlayer.XML
PVS.AVPlayer .NET 3.5
PVS.AVPlayer.XML
PVS.AVPlayer .NET 4.0
PVS.AVPlayer.XML
PVS.AVPlayer .NET 4.5
PVS.AVPlayer .NET 4.5.1
PVS.AVPlayer.XML
PVS.AVPlayer .NET 4.5.2
PVS.AVPlayer.XML
PVS.AVPlayer.XML
PVS.AVPlayer .NET 4.6
PVS.AVPlayer.XML
PVS.AVPlayer.dll
PVS.AVPlayer.XML
PVS.AVPlayer.dll
PVS.AVPlayer.XML
PVS.AVPlayer.dll
PVS.AVPlayer.XML
PVS.AVPlayer.dll
PVS.AVPlayer.XML
PVS.AVPlayer.dll
PVS.AVPlayer.XML
PVS.AVPlayer.dll
PVS.AVPlayer.XML
PVS.AVPlayer.dll
PVS.AVPlayer.XML
PVS.AVPlayer .NET 4.6.1
PVS.AVPlayer.dll
PVS.AVPlayer.XML
PVS.AVPlayer .NET 4.6.2
PVS.AVPlayer.dll
PVS.AVPlayer.XML
PVS.AVPlayer.dll
PVS.AVPlayer.XML
PVS.AVPlayer .NET 4.7
PVS.AVPlayer .NET 4.7.1
PVS.AVPlayer.dll
PVS.AVPlayer.XML
PVS.AVPlayer .NET 4.7.2
PVS.AVPlayer.dll
PVS.AVPlayer.XML
PVS.AVPlayer.dll
PVS.AVPlayer.XML
PVS.AVPlayer All Source Code
AVPlayerExample
AVPlayerExample
AVPlayerExample.csproj.user
bin
Debug
PVS.AVPlayer.XML
Release
Dialogs
Display Overlays
obj
Debug
Release
x86
Debug
Release
Properties
Resources
Crystal Italic1.ttf
WingDings3a.ttf
Voice Recorder
FolderView
FolderView
bin
Debug
PVS.AVPlayer.XML
Release
FolderView.csproj.user
obj
Release
x86
Debug
Release
Properties
Resources
Crystal Italic1.ttf
PVS.AVPlayer
AVPlayerExample.csproj.user
PVS.AVPlayer.dll
PVS.AVPlayer.XML
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
PVS.AVPlayer.XML
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
PVS.AVPlayer.XML
Release
Properties
How To (VB.NET)
PVSAVPlayerHowToVB
bin
Debug
PVS.AVPlayer.dll
PVS.AVPlayer.XML
Release
My Project
Application.myapp
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.Windows.Forms;

#endregion

namespace FolderView
{
    public partial class Form2 : Form
    {
        // A simple PlayerWindow.

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

        # region Fields

        Player      _myPlayer1;
        bool        _userMuted;
        public bool LastError;

        #endregion

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

        #region Main

        public Form2(string theMovie, TimeSpan position)
        {
            InitializeComponent();
            Icon = System.Drawing.SystemIcons.Application;

            positionLabel1.Font = Globals.CrystalFont16;
            positionLabel1.UseCompatibleTextRendering = true;
            positionLabel2.Font = Globals.CrystalFont16;
            positionLabel2.UseCompatibleTextRendering = true;

            Text = theMovie;

            _myPlayer1 = new Player()
            {
                Display = panel1,
                PositionSlider = customSlider21,
                Repeat = true,
            };

            _myPlayer1.MediaPositionChanged += myPlayer1_MediaPositionChanged;
            _myPlayer1.Play(theMovie);
            LastError = _myPlayer1.LastError;

            if (!LastError) _myPlayer1.Position = position;
        }

        // Enable audio when form activated
        private void Form2_Activated(object sender, EventArgs e)
        {
            if (!_userMuted) _myPlayer1.AudioEnabled = true;
        }

        // Mute audio when form deactivated
        private void Form2_Deactivate(object sender, EventArgs e)
        {
            _myPlayer1.AudioEnabled = false;
        }

        // Copied from Form2.Designer.cs to here
        protected override void Dispose(bool disposing)
        {
            if (disposing)
            {
                _myPlayer1.MediaPositionChanged -= myPlayer1_MediaPositionChanged;
                _myPlayer1.Dispose();
                if (components != null) components.Dispose();
            }
            base.Dispose(disposing);
        }

        #endregion

        // ******************************** Player Position Counters Eventhandler

        #region Player Position Counters Eventhandler

        // The playback position of a mediafile has changed - update position info labels
        void myPlayer1_MediaPositionChanged(object sender, EventArgs e)
        {
            TimeSpan[] t = _myPlayer1.GetTrackTimes();
            positionLabel1.Text = t[0].ToString().Substring(0, 8); // hh:mm:ss
            positionLabel2.Text = t[1].ToString().Substring(0, 8);
        }

        #endregion

        // ******************************** Contextmenu Handler

        #region Contextmenu Handler

        // Pause / Resume
        private void pauseMenuItem_Click(object sender, EventArgs e)
        {
            if (_myPlayer1.Paused)
            {
                _myPlayer1.Paused = _userMuted = false;
                pauseMenuItem.Text = "Pause";
            }
            else
            {
                _myPlayer1.Paused = _userMuted = true;
                pauseMenuItem.Text = "Resume";
            }
        }

        // Mute On / Off
        private void muteMenuItem_Click(object sender, EventArgs e)
        {
            if (_myPlayer1.AudioEnabled)
            {
                _myPlayer1.AudioEnabled = false;
                _userMuted = true;
                muteMenuItem.Text = "Mute Off";
            }
            else
            {
                _myPlayer1.AudioEnabled = true;
                _userMuted = false;
                muteMenuItem.Text = "Mute";
            }
        }

        // DisplayMode Stretch
        private void stretchMenuItem_Click(object sender, EventArgs e)
        {
            _myPlayer1.DisplayMode = DisplayMode.Stretch;
            stretchMenuItem.Checked = true;
            zoomAndCenterMenuItem.Checked = false;
        }

        // DisplayMode ZoomAndCenter
        private void zoomAndCenterMenuItem_Click(object sender, EventArgs e)
        {
            _myPlayer1.DisplayMode = DisplayMode.ZoomAndCenter;
            zoomAndCenterMenuItem.Checked = true;
            stretchMenuItem.Checked = false;
        }

        // FullScreen On / Off
        private void fullScreenMenuItem_Click(object sender, EventArgs e)
        {
            if (_myPlayer1.FullScreen)
            {
                _myPlayer1.FullScreen = false;
                fullScreenMenuItem.Text = "FullScreen";
            }
            else
            {
                _myPlayer1.FullScreen = true;
                fullScreenMenuItem.Text = "FullScreen Off";
            }
        }

        // Properties
        private void propertiesMenuItem_Click(object sender, EventArgs e)
        {
            try
            {
                SafeNativeMethods.SHELLEXECUTEINFO info = new SafeNativeMethods.SHELLEXECUTEINFO();
                info.cbSize = System.Runtime.InteropServices.Marshal.SizeOf(info);
                info.lpVerb = "properties";
                info.lpFile = _myPlayer1.GetMediaName(MediaName.FullPath);
                info.nShow = SafeNativeMethods.SW_SHOW;
                info.fMask = SafeNativeMethods.SEE_MASK_INVOKEIDLIST;
                SafeNativeMethods.ShellExecuteEx(ref info);
            }
            catch { }
        }

        // Close
        private void closeMenuItem_Click(object sender, EventArgs e)
        {
            Dispose(true);
        }

        #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 | Cookies | Terms of Use | Mobile
Web03-2016 | 2.8.180712.1 | Last Updated 1 Jun 2018
Article Copyright 2010 by Peter Vegter
Everything else Copyright © CodeProject, 1999-2018
Layout: fixed | fluid