Click here to Skip to main content
14,207,778 members
Click here to Skip to main content
Add your own
alternative version

Stats

761.7K views
31.2K downloads
292 bookmarked
Posted 14 Sep 2010
Licenced CPOL

PVS.AVPlayer - Audio and Video Player Library

, 14 Jun 2019
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 System;
using System.Drawing;
using System.Windows.Forms;

#endregion

namespace AVPlayerExample
{
    // Preferences dialog - application settings.

    public partial class PreferencesDialog : Form
    {
        #region Fields

        private double  _oldOpacity;
        private Form1   _baseForm;
        private bool    _hasMiniPlayers;
        private bool    _oldShowExtensions;

        #endregion

        #region Main / Shown / OnPaint / Closing

        public PreferencesDialog(Form1 baseForm)
        {
            InitializeComponent();
            _baseForm = baseForm;
            ((TextBox)secondsBox.Controls[1]).MaxLength = 5;

            GetPreferences();

            _oldShowExtensions = Form1.Prefs.PlayListShowExtensions;
            _oldOpacity = Opacity;
            Opacity = 0;
        }

        private void PreferencesDialog_Shown(object sender, EventArgs e)
        {
            Application.DoEvents();
            Opacity = _oldOpacity;
        }

        protected override void OnPaint(PaintEventArgs e)
        {
            Rectangle rect = DisplayRectangle;
            rect.Width -= 1;
            rect.Height -= 1;
            Pen pen = new Pen(Color.FromArgb(189, 159, 87), 1);
            e.Graphics.DrawRectangle(pen, rect);
            pen.Dispose();
        }

        private void PreferencesDialog_FormClosing(object sender, FormClosingEventArgs e)
        {
            if (DialogResult == DialogResult.OK)
            {
                SetPreferences();
            }
        }

        #endregion

        #region Get / Set Preferences

        private void GetPreferences()
        {
            saveWindowBox.Checked = Form1.Prefs.SaveWindow;
            saveDisplayModeBox.Checked = Form1.Prefs.SaveDisplayMode;
            saveOverlayBox.Checked = Form1.Prefs.SaveOverlay;
            saveRepeatBox.Checked = Form1.Prefs.SaveRepeat;
            saveSpeedBox.Checked = Form1.Prefs.SaveSpeed;
            saveSliderBox.Checked = Form1.Prefs.SaveSlider;
            autoOverlayBox.Checked = Form1.Prefs.AutoOverlay;
            saveAudioBox.Checked = Form1.Prefs.SaveAudio;

            autoPlayStartBox.Checked = Form1.Prefs.AutoPlayStart;
            autoPlayNextBox.Checked = Form1.Prefs.AutoPlayNext;
            onErrorRemoveBox.Checked = Form1.Prefs.OnErrorRemove;
            onErrorPlayNextBox.Checked = Form1.Prefs.OnErrorPlayNext;
            showExtensionsBox.Checked = Form1.Prefs.PlayListShowExtensions;
            noMessageBox.Checked = !Form1.Prefs.ShowErrorMessages;
            showToolTipsBox.Checked = Form1.Prefs.ShowTooltips;
            if (Form1.Prefs.ShowMiniPlayers) _hasMiniPlayers = true;
            enablePlayersBox.Checked = Form1.Prefs.ShowMiniPlayers; // this triggers enablePlayersBox_CheckedChanged eventhandler (!)

            saveMediaFolderBox.Checked = Form1.Prefs.SaveMediaFilesFolder;
            mediaFilesLabel.Text = Form1.Prefs.MediaFilesFolder;
            savePlaylistBox.Checked = Form1.Prefs.SavePlaylistsFolder;
            playlistsLabel.Text = Form1.Prefs.PlaylistsFolder;

            continuePlayBox.Checked = Form1.Prefs.ContinuePlay;
            secondsBox.Value = Form1.Prefs.RewindSecs;
        }

        private void SetPreferences()
        {
            Form1.Prefs.SaveWindow = saveWindowBox.Checked;
            Form1.Prefs.SaveDisplayMode = saveDisplayModeBox.Checked;
            Form1.Prefs.SaveOverlay = saveOverlayBox.Checked;
            Form1.Prefs.SaveSlider = saveSliderBox.Checked;
            Form1.Prefs.SaveRepeat = saveRepeatBox.Checked;
            Form1.Prefs.SaveSpeed = saveSpeedBox.Checked;
            Form1.Prefs.AutoOverlay = autoOverlayBox.Checked;
            Form1.Prefs.SaveAudio = saveAudioBox.Checked;

            Form1.Prefs.AutoPlayStart = autoPlayStartBox.Checked;
            Form1.Prefs.AutoPlayNext = autoPlayNextBox.Checked;
            Form1.Prefs.OnErrorPlayNext = onErrorPlayNextBox.Checked;
            Form1.Prefs.OnErrorRemove = onErrorRemoveBox.Checked;
            Form1.Prefs.PlayListShowExtensions = showExtensionsBox.Checked;
            Form1.Prefs.ShowErrorMessages = !noMessageBox.Checked;
            Form1.Prefs.ShowTooltips = showToolTipsBox.Checked;
            Form1.Prefs.ShowMiniPlayers = enablePlayersBox.Checked;

            Form1.Prefs.SaveMediaFilesFolder = saveMediaFolderBox.Checked;
            if (Form1.Prefs.SaveMediaFilesFolder) Form1.MediaDirectory = Form1.Prefs.MediaFilesFolder = mediaFilesLabel.Text;
            else Form1.Prefs.MediaFilesFolder = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);

            Form1.Prefs.SavePlaylistsFolder = savePlaylistBox.Checked;
            if (Form1.Prefs.SavePlaylistsFolder) Form1.PlayListDirectory = Form1.Prefs.PlaylistsFolder = playlistsLabel.Text;
            else Form1.Prefs.PlaylistsFolder = Form1.Prefs.MediaFilesFolder;

            Form1.Prefs.ContinuePlay = continuePlayBox.Checked;
            Form1.Prefs.RewindSecs = (int)secondsBox.Value;

            if (Form1.Prefs.PlayListShowExtensions != _oldShowExtensions) _baseForm.ReBuildPlayListMenu();
        }

        private void SetMiniPlayers()
        {
            bool temp = Form1.Prefs.ShowMiniPlayers;

            Form1.Prefs.ShowMiniPlayers = panel2.Visible = panel3.Visible = panel4.Visible = enablePlayersBox.Checked;
            if (enablePlayersBox.Checked && !_hasMiniPlayers)
            {
                _baseForm.SetDialogMiniPlayers(panel2, panel3, panel4);
                _hasMiniPlayers = true;
            }

            Form1.Prefs.ShowMiniPlayers = temp;
        }

        #endregion

        #region Buttons / Labels Click

        private void OKButton_Click(object sender, EventArgs e)
        {
            DialogResult = DialogResult.OK;
            Close();
        }

        private void cancelButton_Click(object sender, EventArgs e)
        {
            Close();
        }

        private void mediaFilesLabel_Click(object sender, EventArgs e)
        {
            OKButton.Focus();
            FolderBrowserDialog dlg = new FolderBrowserDialog()
            {
                Description = Text + "\r\n\r\nPlease select the initial folder to browse for mediafiles:",
                ShowNewFolderButton = true,
                SelectedPath = mediaFilesLabel.Text
            };
            if (dlg.ShowDialog(this) == DialogResult.OK)
            {
                mediaFilesLabel.Text = dlg.SelectedPath;
                saveMediaFolderBox.Checked = true;
            }
            dlg.Dispose();
        }

        private void playlistsLabel_Click(object sender, EventArgs e)
        {
            OKButton.Focus();
            FolderBrowserDialog dlg = new FolderBrowserDialog()
            {
                Description = Text + "\r\n\r\nPlease select the initial folder to browse for playlists:",
                ShowNewFolderButton = true,
                SelectedPath = playlistsLabel.Text
            };
            if (dlg.ShowDialog(this) == DialogResult.OK)
            {
                playlistsLabel.Text = dlg.SelectedPath;
                savePlaylistBox.Checked = true;
            }
            dlg.Dispose();
        }

        private void enablePlayersBox_CheckedChanged(object sender, EventArgs e)
        {
            SetMiniPlayers();
        }

        private void secondsBox_Click(object sender, EventArgs e)
        {
            continuePlayBox.Checked = true;
        }

        private void secondsBox_KeyDown(object sender, KeyEventArgs e)
        {
            // the length of the input is limited to 5 digits in the dialog's constructor
            // here, don't allow typing the minus, decimal or comma chars:
            if (e.KeyCode == Keys.Subtract || e.KeyCode == Keys.OemMinus
                || e.KeyCode == Keys.Decimal || e.KeyCode == Keys.OemPeriod
                || e.KeyCode == Keys.Oemcomma)
            {
                System.Media.SystemSounds.Beep.Play();
                e.SuppressKeyPress = true;
                e.Handled = true;
            }
        }

        private void label5_Click(object sender, EventArgs e)
        {
            continuePlayBox.Checked = !continuePlayBox.Checked;
        }

        #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

Permalink | Advertise | Privacy | Cookies | Terms of Use | Mobile
Web04 | 2.8.190612.1 | Last Updated 14 Jun 2019
Article Copyright 2010 by Peter Vegter
Everything else Copyright © CodeProject, 1999-2019
Layout: fixed | fluid