Use the DirectShow control in Microsoft Visual C #. NET to develop a media player. Following the procedure described in this article, you can create a simple Visual C # application that plays digital audio and video.
Introduced
Microsoft Visual C # is the world's most popular programming language, with the latest version of Visual C #. NET, which enables you to quickly and efficiently develop Windows Forms-based applications, as well as embed Microsoft Windows Media? The Player 9 Series ActiveX Control application adds fresh, interesting, and very useful features.
The DirectShow control is a standard ActiveX control that provides a number of features. The features that the DirectShow control provides include:
· Advanced playback capabilities for digital media files and streaming media.
· The ability to use playlists.
· Play DVD and CD features.
· Access the Media Library in Windows media Player.
· The ability to process metadata.
· Subtitles are supported.
· Supports audio in multiple languages.
· The ability to control network connectivity and access related statistics.
Let's take a look at what kind of target the media player is going to achieve and determine the amount of code and the complexity of the program. The media player in this article achieves the following objectives:
· is a simple menu-driven AWT application.
· Contains a File menu that contains three menu items:
· Open to open the media file.
· Loop, which is played once (the default) or repeated.
· "Exit" to exit the program.
· Can be run on multiple platforms.
· The core functionality is implemented through the JMF (Java Media Framework) API.
Following the steps in this article, you will create a basic Windows forms-based application and embed the Player control in it. The sample application that you create has the following characteristics:
· Creates an instance of the DirectShow control.
· Provides Component Object Model (COM) interoperability with the Windows Media Player Primary Interop Assemblies.
· Allows users to open and play Windows Media files, especially files with a. wma or. wmv file name extension.
· Create a Transport control button for users to play, pause, and stop digital media content.
· Displays the title of the current digital media file.
· Demonstrates how to use the Player object model, including examples that use properties, methods, and events.
My program just tells you how to do a player in C # with DirectShow,
In this program we have to solve some of the minor problems:
1. How to open a media file from your disk
2. How to enable and Disable buttons on the toolbar
3. How to set the display text for the status bar
4. How to control time
5. How to use events for a Time control
6. How to use DirectShow to play media files
7. How to determine the playback status, etc...
Shows the application you are about to create, which is playing a digital audio file named "Melow", while rendering the visualization.
This article assumes that you already have some knowledge of the integrated development environment for Visual C # and Visual Studio.NET.
Preparatory work
Before you begin to create an application, you need to install the necessary software and register the primary interop assembly (QuartzTypeLib).
Here is a brief introduction to the DirectShow interface:
Play video and sound files we need to use the DirectShow component that DIECTX provides for us. Using this interface allows you to easily play those shared images and sound files. All you have to do is install the DirectShow interface and use its function functions and configure the correct interface parameters only.
Unfortunately, it is. NET does not formally support DirectX. Yes, well, maybe you heard about DirectX9 's support, right? Yes, but we didn't get the best results on the day the final version was finalized. But we're going to have to use it anyway, right? That's it, that's what we're going to use.
Start Project
After installing the necessary software and registering QuartzTypeLib, you can start Visual C # and start creating a project for the sample application. I'll show you the steps in this process.
Create a project
Follow these steps to create an empty project:
- Start Visual Studio. NET, and then click New Project.
2. In the Visual C # Projects (Visual C # Project) folder, click Windows Application (Windows application), type the name of the new project (preferably DirectShow), and then click OK.
Visual C # uses the default Windows forms "Form1" to create a new project.
3. This name does not have any particular meaning or usefulness, so change the form name to Frmplaymedia in the Properties window, changing the form text to media Player.
Add a reference to DirectShow in your project
Follow these steps to add a reference to the DirectShow in your project:
1. Open the Visual Studio Toolbox and click Components to display the panel.
2. Right click on the panel and click Customize Toolbox (Customize Toolbox) to display the dialog box.
3. On the COM Components tab, select Interop.QuartzTypeLib.dll. (if Interop.QuartzTypeLib.dll is not listed for some reason, click Browse and look for a file named QuartzTypeLib.dll.) )
4. Click OK to close the dialog box.
To use DirectShow in your code, you need to add a line of code to reference the DirectShow namespace. At the top of the form code window, add the following code before all the declaration statements:
Using QuartzTypeLib;
The using statement must be after all Options statements (not used in this project), and before all other code. After the statement is added.
Media Player developed in C #