A Windows Media Player Control let you play mp3 or wav files with a unique line of vb.net code:
Me.AxWindowsMediaPlayer1.URL = dlgFileDialog.FileName
Create a new VBA windows application in Visual Studio.
Add the Media Player control to the toolbox.
Right-click the toolbox and choose Add/Remove Iitems�
In the Customize Toolbox chose the COM Components Panel and navigate to Windows Media Player and select it.

Confirm with OK Button.
Add the control to the Main form.
Select the Windows Media Player in the toolbox and ad it to the main form.
Change the Visible property of the control to false.

Add a Button control to the main form.

Double-click the Button and add the following code to the Click-event procedure.
Private Sub Button1_Click(ByVal sender As System.Object, _ ByVal e As System.EventArgs) _ Handles Button1.Click Const DATA_FILE_EXTENSION As String = ".mp3" Dim dlgFileDialog As New OpenFileDialog With dlgFileDialog .Filter = DATA_FILE_EXTENSION & _ " files (*" & DATA_FILE_EXTENSION & "|*" & DATA_FILE_EXTENSION .FilterIndex = 1 .RestoreDirectory = True If .ShowDialog() = DialogResult.OK Then 'Play the sound file Me.AxWindowsMediaPlayer1.URL = dlgFileDialog.FileName End If End With End Sub
| You must Sign In to use this message board. | |||||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||||