Procedure Name | Type | Description |
(Declarations) | Declarations | Declarations and private variables for the modWindowsMediaPlayer module. |
WMPControlLoad | Procedure | Plays a media file in the specified Windows Media Player control. |
WMPControlPlay | Procedure | Plays the file loaded in the Windows Media Player control. |
WMPControlPause | Procedure | Pauses or resumes the file playing in the Windows Media Player control. |
WMPControlStop | Procedure | Stops the file playing in the Windows Media Player control. |
WMPControlVolume | Procedure | Adjusts the volume in a Windows Media Player control. |
WMPControlMute | Procedure | Turns off the volume to mute the Windows Media Player control. |
LaunchWMP | Procedure | Launches the specified file in Windows Media Player. |
' Example of modWindowsMediaPlayer ' ' To try this example, do the following: ' 1. Create a new form ' 2. Add the following command buttons ' Command0 ' Command1 ' Command2 ' Command3 ' Command4 ' Command5 ' Command6 ' Command7 ' 3. Add a text box named txtPath ' 4. Add a Windows Media Player control named wmpTest ' 5. Paste this code into the form's module ' Constant for the default multimedia file. Others include C:\Total Visual SourceBook 2013\Samples\test.wav, C:\Users\Public\Music\Sample Music\*.wma, etc. Const mcstrSamp As String = "C:\Total Visual SourceBook 2013\Samples\test.avi" Private Sub Command0_Click() ' Load If Nz(Me.txtPath, "") = "" Then MsgBox "Please specify a file to play." Me.txtPath = mcstrSamp Me.txtPath.SetFocus Else WMPControlLoad Me.wmpTest.Object, Me.txtPath End If End Sub Private Sub Command1_Click() ' Play WMPControlPlay Me.wmpTest.Object End Sub Private Sub Command2_Click() 'Pause WMPControlPause Me.wmpTest.Object End Sub Private Sub Command3_Click() ' Stop WMPControlStop Me.wmpTest.Object End Sub Private Sub Command4_Click() ' Increase Volume WMPControlVolume Me.wmpTest.Object, False, 10 End Sub Private Sub Command5_Click() ' Decrease Volume WMPControlVolume Me.wmpTest.Object, True, 10 End Sub Private Sub Command6_Click() ' Mute WMPControlMute Me.wmpTest.Object End Sub Private Sub Command7_Click() ' Launch WMP If Nz(Me.txtPath, "") = "" Then MsgBox "Please specify a file to play." Me.txtPath = mcstrSamp Me.txtPath.SetFocus Else LaunchWMP (Me.txtPath) End If End Sub Private Sub Form_Load() ' Setup controls Me.Command0.Caption = "Load" Me.Command1.Caption = "Play" Me.Command2.Caption = "Pause" Me.Command3.Caption = "Stop" Me.Command4.Caption = "Vol +" Me.Command5.Caption = "Vol -" Me.Command6.Caption = "Mute" Me.Command7.Caption = "Launch WMP" Me.txtPath = mcstrSamp End Sub
The source code in Total Visual Sourcebook includes modules and classes for Microsoft Access, Visual Basic 6 (VB6), and Visual Basic for Applications (VBA) developers. Easily add this professionally written, tested, and documented royalty-free code into your applications to simplify your application development efforts.
Total Visual SourceBook is written for the needs of a developer using a source code library covering the many challenges you face. Countless developers over the years have told us they learned some or much of their development skills and tricks from our code. You can too!
Supports Access/Office 2016, 2013, 2010 and 2007, and Visual Basic 6.0!
"The code is exactly how I would like to write code and the algorithms used are very efficient and well-documented."
Van T. Dinh, Microsoft MVP