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 );