Click here to Skip to main content
14,212,087 members
Click here to Skip to main content

Stats

764.1K views
31.6K downloads
295 bookmarked

PVS.AVPlayer - Audio and Video Player Library

,
Rate this:
4.94 (153 votes)
Please Sign up or sign in to vote.
4.94 (153 votes)
14 Jun 2019     CPOL    
Microsoft Media Foundation (MF) based easy-to-use 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 .NET 4.8
PVS.AVPlayer.dll
PVS.AVPlayer.XML
PVS.AVPlayer Licenses
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.png
Dial Normal 2.png
Dial Red 2.png
Dial Red.png
Kaizen-4.png
Media Normal.ico
Media Paused.ico
Media Paused1.ico
Media Playing.ico
PVSLogo.png
PVSLogoOutline.png
VU Meter.png
WingDings3a.ttf
Various
PVS.AVPlayer Licenses
About Dialog
PVS.AVPlayer.dll
PVS.AVPlayer.XML
Custom Items
FolderView.csproj.user
Media8b.ico
Debug
Bob.png
Crystal Italic1.ttf
Media Paused.ico
media7a.ico
media7b.ico
Media8a.ico
Media8b.ico
PVSLogoOutline.png
Subtitles Overlay
Various
PVS.AVPlayer Licenses
How To (C#)
PVS.AVPlayer Licenses
PVSAVPlayerHowTo
bin
Debug
PVS.AVPlayer.dll
PVS.AVPlayer.XML
Release
obj
Debug
Release
Properties
How To (VB.NET)
PVS.AVPlayer Licenses
PVSAVPlayerHowToVB
bin
Debug
PVS.AVPlayer.dll
PVS.AVPlayer.XML
Release
My Project
Application.myapp
obj
Debug
Release
PVSAVPlayerHowTo.vbproj.user
PVS.AVPlayer Licenses
PVS.AVPlayer Examples
AVPlayerExample.ex_
FolderView.ex_
AVPlayerExample.exe
FolderView.exe
PVS.AVPlayer Licenses
PVS.AVPlayer.dll
#region Usings

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

#endregion

namespace PVSAVPlayerHowTo
{
    public partial class Overlay : Form
    {

        // This is a sample PVS.AVPlayer display overlay:
        // it shows a label with the text "Display Overlay" on top of movies.
        // As an example of overlay 'animation' the text is made 'flashing'.

        // The background color is 'close' to the text color to prevent
        // visible 'borders' around the letters of the text.

        // The text remains in the middle of the video image because
        // the label is 'anchored' on all sides of the form and the
        // text is centered (TextAlign MiddleCenter).

        // The display overlay (form) also contains a label
        // that is used to display subtitles.


        // Special items (optional but highly recommended - see code below):

        // A few options (ShowWithoutActivation and (overwrite) WndProc) are used to prevent 'flashing'
        // of the overlay when it is displayed or clicked on.

        // To use the player option to drag the display window, you must use a mousedown eventhandler
        // provided by the player (Player.Display.Drag_MouseDown) for the overlay and any control on it
        // (which must start dragging the display of the player when clicked).

        // The 'heart' of every display overlay is the VisibleChanged event handler. It is called when
        // the overlay is activated or deactivated.


        // About the transparency of display overlays:

        // PVS.AVPlayer makes overlays transparent by setting the TransparencyKey property of the overlay
        // (form) to the same color as the background color of the overlay. You can set these colors yourself
        // if you want. The 'mouseclick transparency' of the overlay depends on the colors used. For example,
        // 'Green' makes mouse clicks 'fall through', but 'RosyBrown' does not.
        // More information can be found on the internet.


        // **** Class Fields **************************************************************************

        #region Class Fields

        private readonly Color  FOREGROUND_COLOR    = Color.Red; // = 255, 0, 0
        private readonly Color  BACKGROUND_COLOR    = Color.FromArgb(200, 0,0);
        private const int       TIMER_INTERVAL      = 600;

        private Player          basePlayer;
        private Timer           flashTimer;         // the timer used for flashing text
        private bool            flashOn;            // the state of the flashing text
        private bool            isDisposed;         // used with cleaning up

        #endregion


        #region Main

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

        // the display overlay constructor
        public Overlay(Player player)
        {
            InitializeComponent();

            basePlayer = player;
            subtitlesLabel.Text = "";

            flashTimer          = new Timer();
            flashTimer.Interval = TIMER_INTERVAL;
            flashTimer.Tick     += FlashTimer_Tick;
        }

        // Don't activate form when shown
        protected override bool ShowWithoutActivation
        {
            get { return true; }
        }

        // Don't activate form with mouse click
        protected override void WndProc(ref Message m)
        {
            const int WM_MOUSEACTIVATE  = 0x0021;
            const int MA_NOACTIVATE     = 0x0003;

            if (m.Msg == WM_MOUSEACTIVATE) m.Result = (IntPtr)MA_NOACTIVATE;
            else base.WndProc(ref m);
        }

        // the animation (timer) is switched on/off when the form's visibility changes, the form's
        // visibility (among other) changes when the overlay is activated/deactivated by the player:
        private void Overlay_VisibleChanged(object sender, System.EventArgs e)
        {
            if (this.Visible)
            {
                flashOn = false;
                flashLabel.ForeColor = FOREGROUND_COLOR;
                flashTimer.Start();

                // enable dragging of the main display (if  enabled)
                this.MouseDown           += basePlayer.Display.Drag_MouseDown;
                flashLabel.MouseDown     += basePlayer.Display.Drag_MouseDown;
                subtitlesLabel.MouseDown += basePlayer.Display.Drag_MouseDown;
            }
            else
            {
                flashTimer.Stop();

                this.MouseDown           -= basePlayer.Display.Drag_MouseDown;
                flashLabel.MouseDown     -= basePlayer.Display.Drag_MouseDown;
                subtitlesLabel.MouseDown -= basePlayer.Display.Drag_MouseDown;
            }
        }

        // here the 'animation' (text flashing) is done
        private void FlashTimer_Tick(object sender, System.EventArgs e)
        {
            if (flashOn) flashLabel.ForeColor = FOREGROUND_COLOR;
            else flashLabel.ForeColor = BACKGROUND_COLOR;

            flashOn = !flashOn;
        }

        // clean up - this is moved here from the 'Overlay.Designer.cs' file and appended:
        protected override void Dispose(bool disposing)
        {
            if (!isDisposed)
            {
                isDisposed = true;
                if (disposing)
                {
                    if (flashTimer != null) flashTimer.Dispose();
                    // used by the designer - clean up:
                    if (components != null) components.Dispose();
                }
            }
            base.Dispose(disposing);
        }

        #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

Layout: fixed | fluid

Article Copyright 2010 by Peter Vegter
Everything else Copyright © CodeProject, 1999-2019

Server Web01
Version 2.8.190619.2