C # play audio files

Source: Internet
Author: User

First, apply wmp. dll under C: WINDOWSsystem32 to the project;

WMPLib. WindowsMediaPlayerClass player = new WMPLib. WindowsMediaPlayerClass ();
Player. URL = @ "F: ding.wav ";
Player. uiMode = "None ";
Player. settings. volume = 100;
Player. settings. playCount = 1;
Player. play ();

WMPLib. WindowsMediaPlayer usage

 

Attribute/method name: Description:
[Basic attributes]
URL: String; specifies the media location, local or network address
UiMode: String; player interface mode, which can be Full, Mini, None, Invisible
PlayState: integer; playback status, 1 = stopped, 2 = paused, 3 = played, 6 = buffering, 9 = connected, 10 = ready
EnableContextMenu: Boolean; enable/disable context menu
FullScreen: boolean; Whether to display in full screen
[Controls] wmp. controls // basic player control
Controls. play; play
Controls. pause; pause
Controls. stop; stop
Controls. currentPosition: double; current progress
Controls. currentPositionString: string; current progress, string format. For example"
Controls. fastForward; Fast Forward
Controls. fastReverse; fast return
Controls. next; next
Controls. previous; previous Curve
[Settings] wmp. settings // basic player settings
Settings. volume: integer; volume: 0-100
Settings. autoStart: Boolean; Whether to play automatically
Settings. mute: Boolean; mute
Settings. playCount: integer; number of playbacks
[CurrentMedia] wmp. currentMedia // current media attribute
CurrentMedia. duration: double; total media Length
CurrentMedia. durationString: string; total media length, in string format. For example"
CurrentMedia. getItemInfo (const string); get current media information "Title" = media Title, "Author" = artist, "Copyright" = Copyright information, "Description" = media content Description, "Duration" = Duration (seconds), "FileSize" = file size, "FileType" = file type, "sourceURL" = original address
CurrentMedia. setItemInfo (const string); set media information by attribute name
CurrentMedia. name: string; same as currentMedia. getItemInfo ("Title ")
[CurrentPlaylist] wmp. currentPlaylist // attributes of the current playlist
CurrentPlaylist. count: integer; number of media contained in the current playlist
CurrentPlaylist. Item [integer]; gets or sets the media information of the specified project. Its subattributes are the same as that of wmp. currentMedia.

Loop playback: currentMedia. settings. setMode ("loop", true );

Cancel loop: currentMedia. settings. setMode ("loop", false );

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.