C # Call Windows Media Player to create a player

Source: Internet
Author: User

Right-click the toolbox and choose items.->Show "select toolbox items"->COM Component->WindowsMediaPlayer WMP. dllAdd

 

Mymediaplayer form

Public Static string Path = ""; // record the complete path of the file
String duration = ""; // time when the current file is played
Int width = 0; // The width of the playback File
Int Height = 0; // The height of the playback File
// The storage path key is the file name, and the value is the complete path
Private dictionary <string, string> pathlist = new dictionary <string, string> ();
Private void open the file toolstripmenuitem_click (Object sender, eventargs E)
{


This. openfile ();
// Clear all values in the playlist
This. listview1.items. Clear ();
// Clear the set
Pathlist. Clear ();
// Add to listview
Listviewupdate (path. getfilename (PATH), PATH );
// Play
Axwmp. url = path;
// When the playback file is opened, start the timer control to get the file time and width and height.
// If it is placed in the current position, the resulting value is 0,
// It may take some time to open a media file. The media file is waiting for opening.
Timer1.start ();

}
Private void openfile (){
// Open a file
Openfiledialog ofd = new openfiledialog ();
Dialogresult DR = ofd. showdialog ();
If (DR = dialogresult. Cancel)
{// Cancel opening
Return;
}
// Otherwise, the record opens the path
Path = ofd. filename;


}
Private void attribute toolstripmenuitem_click (Object sender, eventargs E)
{
// Record only the file name
// String S = path. getfilenamewithoutextens Ion (PATH );
// Record the file name and extension
String Ss = path. getfilename (PATH );
// Playback File Information
Musicinfo MI = new musicinfo (SS, duration, width, height );
Mi. showdialog ();

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.