C #. Use System. Media. soundplayer to play music in VB. NET.

Source: Internet
Author: User

I have posted a blog post on C #/. net using the mediaplayer control to play MP3 and other music files. Today I will talk about using the class library that comes with. net.System. MediaThe followingSoundplayerTo play music.CodeIt should be a more desirable method.

It is very easy to use. The following is a brief description:

1. Support synchronous and asynchronous playback

2. Supports loop playback.

3. Support for file and stream playback

Synchronous playback:

 
System. Media. soundplayer player =NewSystem. Media. soundplayer (); player. soundlocation = @"D: \ music \ happy.pdf"; Player. Load (); player. Play ();

Asynchronous playback:

 
System. Media. soundplayer player =NewSystem. Media. soundplayer (); player. soundlocation = @"D: \ music \ happy.pdf"; Player. loadasync (); player. playsync ();

Loop playback:

System. Media. soundplayer player =NewSystem. Media. soundplayer (); player. soundlocation = @"D: \ music \ happy.pdf"; Player. Load (); player. playlooping ();

OK. I hope I can give you a prompt!

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.