winform form to add background music (three ways)

 

winform form to add background music (three ways)

 1: Use the controls Microsoft MutileMedia Control Version 6.0, you can add this control in Vs.net.
   Named Player.  
      'Playing background music  
                                        player.FileName = Application.StartupPath "/Music/GameMain.mid"  
                                         player.Command = "Open "  
                                       player.Command =" play "
in this way I tested you can play music files wma and wmv format, but also in the new window will be playing wmv


2. You can use directx hosted DirectX.AudioVideoPlayback.DLL 9 which has a class of life, you can in C: folder inside the Microsoft.net find this file, use this category Audio, used to play sound

Music is very convenient,
Audio v = Audio ( "MP3.");
V.ending + = new new ..... // add an event handler!

In his event handler where you can write
v.open ( "sound file name!")
V.play ();
details can deal with their own on the line! 

 

3. You can use SoundPlayer.PlaySync method to asynchronously load the file and play.

----------------------------------- ---------------------------------------------
environment how Winform , add background music to the form?

For example:
Private the SoundPlayer the SoundPlayer Player new new = (); // NEW a first player
Private void loadSoundAsync ()
{
// Note: On May by You need to Change The specified based LOCATION ON
. // The LOCATION of The Sound BE Played to
the this = .Player.SoundLocation "http://www.tailspintoys.com/sounds/stop.wav";
this.Player.LoadAsync ();
}

Private void Player_LoadCompleted (
Object SENDER,
System.ComponentModel.AsyncCompletedEventArgs E)
{
IF (the this .Player.IsLoadCompleted)
{
this.Player.PlaySync ();
}
}

// This example is to find the local background
this.axWindowsMediaPlayer1.URL = @ "F: / MS / 09 Love Rice .mp3";
this.axWindowsMediaPlayer1.Visible = to false;

Reproduced in: https: //www.cnblogs.com/baishiying/archive/2012/08/29/2662114.html

 1: Use the controls Microsoft MutileMedia Control Version 6.0, you can add this control in Vs.net.
   Named Player.  
      'Playing background music  
                                        player.FileName = Application.StartupPath "/Music/GameMain.mid"  
                                         player.Command = "Open "  
                                       player.Command =" play "
in this way I tested you can play music files wma and wmv format, but also in the new window will be playing wmv


2. You can use directx hosted DirectX.AudioVideoPlayback.DLL 9 which has a class of life, you can in C: folder inside the Microsoft.net find this file, use this category Audio, used to play sound

Music is very convenient,
Audio v = Audio ( "MP3.");
V.ending + = new new ..... // add an event handler!

In his event handler where you can write
v.open ( "sound file name!")
V.play ();
details can deal with their own on the line! 

 

3. You can use SoundPlayer.PlaySync method to asynchronously load the file and play.

----------------------------------- ---------------------------------------------
environment how Winform , add background music to the form?

For example:
Private the SoundPlayer the SoundPlayer Player new new = (); // NEW a first player
Private void loadSoundAsync ()
{
// Note: On May by You need to Change The specified based LOCATION ON
. // The LOCATION of The Sound BE Played to
the this = .Player.SoundLocation "http://www.tailspintoys.com/sounds/stop.wav";
this.Player.LoadAsync ();
}

Private void Player_LoadCompleted (
Object SENDER,
System.ComponentModel.AsyncCompletedEventArgs E)
{
IF (the this .Player.IsLoadCompleted)
{
this.Player.PlaySync ();
}
}

// This example is to find the local background
this.axWindowsMediaPlayer1.URL = @ "F: / MS / 09 Love Rice .mp3";
this.axWindowsMediaPlayer1.Visible = to false;

Guess you like

Origin blog.csdn.net/weixin_33895604/article/details/93439977