Play MP3, MP4 files in WinForm

Source: Internet
Author: User

1. On the VS2012 Toolbox right---"select"-"COM Components" and "Windows Media Player" Tick on, then click OK.

2. In the WinForm form, add two button buttons, one Windows Media Player, and the corresponding

The button code is as follows:

Play Music private void button1_click (object sender, EventArgs e) {FileDialog open = new OpenFileDialog (); WxWindowsMediaplayer1 is the control name This.axWindowsMediaPlayer1.settings.playCount = 2;//played; ope            N.filter = "*.mp3|*.mp3"; Open.            Title = "Open File"; if (open. ShowDialog () = = DialogResult.OK) {axwindowsmediaplayer1.url = open.                FileName; AxWindowsMediaPlayer1.Ctlcontrols.play ();//Play File}}//play video private void Button2_Click (object sender, Eve            Ntargs e) {FileDialog open = new OpenFileDialog (); WxWindowsMediaplayer1 is the control name This.axWindowsMediaPlayer1.settings.playCount = 2;//played; open. Filter = "*.mp4|*.mp4"; File format Open.            Title = "Open File"; if (open. ShowDialog () = = DialogResult.OK) {axwindowsmediaplayer1.url = open.                FileName; AxWindowsMediaPlayer1.Ctlcontrols.play ();Play file}} 

:

If there is a wrong place, look at the garden friends to point out!

Play MP3, MP4 files in WinForm

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.