C # Video Player using Microsoft DirectX

Source: Internet
Author: User
C # Video Player using Microsoft DirectX
Using System;
Using System. Collections. Generic;
Using System. ComponentModel;
Using System. Data;
Using System. Drawing;
Using System. Text;
Using System. Windows. Forms;
Using Microsoft. DirectX. AudioVideoPlayback;
Namespace playVideoProject
{
Public partial class Form1: Form
{
Private Video myvideo = null;
Public Form1 ()
{
InitializeComponent ();
}
Private void button#click (object sender, EventArgs e)
{
OpenFile. InitialDirectory = Application. StartupPath; // obtain the initial directory displayed in the dialog box.
If (openFile. ShowDialog () = DialogResult. OK)
{
// Record the size of the panel component
Int height = panel1.Height;
Int width = panel1.Width;
// If an opened Video file exists, release it.
If (myvideo! = Null)
{
Myvideo. Dispose ();
}
// Open a new Video file
Myvideo = new Video (openFile. FileName );
// Allocate the Video file to the created Panel component.
Myvideo. Owner = panel1;
// Redefines the size of the record panel component
Panel1.Width = width;
Panel1.Height = height;
// Play the first frame of the AVI file, mainly to display it in the panel
Myvideo. Play ();
Myvideo. Pause ();
}
// Determine the status of buttons in the form
If (myvideo = null)
{
Button2.Enabled = false;
Button3.Enabled = false;
Button4.Enabled = false;
}
Else
{
Button2.Enabled = true;
Button3.Enabled = true;
Button4.Enabled = true;
}
}
Private void button3_Click (object sender, EventArgs e)
{
If (myvideo! = Null)
{
Myvideo. Pause ();
}
}
Private void button2_Click (object sender, EventArgs e)
{
If (myvideo! = Null)
{
Myvideo. Play ();
}
}
Private void Form1_Load (object sender, EventArgs e)
{
If (myvideo = null)
{
Button2.Enabled = false;
Button3.Enabled = false;
Button4.Enabled = false;
}
Else
{
Button2.Enabled = true;
Button3.Enabled = true;
Button4.Enabled = true;
}
}
Private void button4_Click (object sender, EventArgs e)
{
If (myvideo! = Null)
{
Myvideo. Stop ();
}
}
Private void panelappspaint (object sender, PaintEventArgs e)
{
}
}
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.