My Media Player--multimedia programming

Source: Internet
Author: User

The second topic is my player, which can play audio and video. In fact, a little knowledge of computer multimedia technology, people are aware that audio and video differences are embodied in the file format. Different audio mp3,midi,wav are actually different encoding or format, the same as different video avi,rm (RMVB), MOV, etc. is actually a different encoding format, these formats, most of them are unfair open source code, but the public standard or API interface. But programming calls are still cumbersome, and we don't have the energy and the ability to study them.

. NET itself does not have a multimedia library, but it has the power to interact with COM. Exactly, Microsoft DirectShow technology can meet the above requirements, and can follow. NET achieves the perfect union.

DirectShow Interactive Assembly is integrated in DirectX, most computers will have DirectX, Microsoft also provides downloads. Cut the crap and start doing it.

First, refer to Interop.QuartzTypeLib.dll in the project. This is the COM interactive assembly for DirectX, which is actually a managed call. The class library and method introductions are best seen in DirectX SDK. There's no fish to swim here.

Second, play the open file

public void Rendermedia (string mediafilename)
{
Clearup ();
Try
{
Objmedia = new Filgraphmanager ();
Objmedia.renderfile (mediafilename);
Volmedia = Objmedia as Ibasicaudio;
Posmedia = Objmedia as imediaposition;
Ctlmedia = Objmedia as IMediaControl;
Eexmedia = Objmedia as Imediaeventex;
Eexmedia.setnotifywindow (int) this.        Handle, wm_graphnotify, 0);
Mediastatus = 1;
Mediaduration = posmedia.duration;
Volmedia.volume = Mediavolum;
Play ();
catch
{
MessageBox.Show ("Failed to load file!");
Clearup ();
}
}

Related Article

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.