Welcome to Dream.In.Code
Getting VB Help is Easy!

Join 136,549 VB Programmers for FREE! Get instant access to thousands of VB experts, tutorials, code snippets, and more! There are 1,875 people online right now. Registration is fast and FREE... Join Now!




Play WAV in VB6 Using Windows Media Player

 
Reply to this topicStart new topic

Play WAV in VB6 Using Windows Media Player

OcalaHugh
19 Aug, 2008 - 02:47 AM
Post #1

New D.I.C Head
*

Joined: 19 Aug, 2008
Posts: 5


My Contributions
The following code used to work. It still works for an old version I have of wmplayer.exe from windows98.

The code woul permit wmplayer to load and play the assigned WAV file.

Any Help would be appreciated.

vb

'------------------------------------
' PlaySound
'-------------------------------
'
'
If Winver = "None" Then
Exit Sub
End If

On Error GoTo err1:
Dim a, b1
'---------------------------
' Calculate the pause time
'---------------------------
'
'
'

b1 = SoundPath + SoundFile 'works

a = Shell(Winver + " " + b1, 0) ' works
'
'----------------------------
' Make a pause to play sound
'----------------------------
'
'
FindSize
Exit Sub
err1:
Err.Clear

End Sub

=====================
Notes:

Winver = "C;\Program Files\ Windows Media Player\wmplayer"
b1 = SoundPath + SoundFile


FindSize is used to determine a Pause time

Thank,
Hugh Haggerty

Mod Edit: Please use code tags when posting your code. Code tags are used like so => code.gif

Thanks,
PsychoCoder smile.gif
User is offlineProfile CardPM
+Quote Post

OcalaHugh
RE: Play WAV In VB6 Using Windows Media Player
20 Aug, 2008 - 05:58 PM
Post #2

New D.I.C Head
*

Joined: 19 Aug, 2008
Posts: 5


My Contributions
I have found an easy solution to this problem and will post it in the morning.
User is offlineProfile CardPM
+Quote Post

OcalaHugh
RE: Play WAV In VB6 Using Windows Media Player
23 Aug, 2008 - 09:19 AM
Post #3

New D.I.C Head
*

Joined: 19 Aug, 2008
Posts: 5


My Contributions
QUOTE(OcalaHugh @ 19 Aug, 2008 - 03:47 AM) *

The following code used to work. It still works for an old version I have of wmplayer.exe from windows98.

The code woul permit wmplayer to load and play the assigned WAV file.

Any Help would be appreciated.

vb

'------------------------------------
' PlaySound
'-------------------------------
'
'
If Winver = "None" Then
Exit Sub
End If

On Error GoTo err1:
Dim a, b1
'---------------------------
' Calculate the pause time
'---------------------------
'
'
'

b1 = SoundPath + SoundFile 'works

a = Shell(Winver + " " + b1, 0) ' works
'
'----------------------------
' Make a pause to play sound
'----------------------------
'
'
FindSize
Exit Sub
err1:
Err.Clear

End Sub

=====================
Notes:

Winver = "C;\Program Files\ Windows Media Player\wmplayer"
b1 = SoundPath + SoundFile


FindSize is used to determine a Pause time

Thank,
Hugh Haggerty

Mod Edit: Please use code tags when posting your code. Code tags are used like so => code.gif

Thanks,
PsychoCoder smile.gif


--------------- Here is a better solution ------------
The solution to making the Windows Media Player operate in a program is simple.

1. Go to Project Components
2. Check the Media box
3. Put the media icon on your form sheet
4, Put the following code in the Declaration section of a module to make it available to all forms

<code>

Declare Function sndPlaySound Lib "winmm.dll" Alias "sndPlaySoundA" (ByVal lpszSoundName As String, ByVal uFlags As Long)

</code>

5. Put a command button on your form and copy the following code in to subroutine

<code>

Private Sub Command1_Click()
Dim s1
' s1 is the location of your WAV file
s1 = "c:\VectorSounds\numberline.wav"
'
' s1 is the path and name of the wav file
WindowsMediaPlayer1.URL = s1

'
</code>

6. If you do not want the mediam player visible, go to the attributes table and change it.
7. This will open the Windows Media Player is asynchronous mode . If you find out how to open the Windows Media Player is

synchronous mde, please drop me an email. h.a.haggerty@earthlink.net


User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 12/2/08 11:09PM

Live VB Help!

VB Tutorials

Reference Sheets

VB Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month