|
-
Aug 13th, 2000, 11:49 AM
#1
Thread Starter
Member
Hey i'm new here. I've tried everything from asking my boss if he knew Visual basic to my teacher who teaches visual basic and so far i have come up with nothing. I'm writing this program for a friend and trying to learn more about the concept of programming and I want to basically click on an option box and have it play a wav file. But the first problem i have is that visual basic doesnt seem to like to read files outside of the A drive.. or thats what my teacher seemed to explain to us. He couldnt get it working by using the hard drive or any other drive for that matter.. just the "A" drive.. which isnt user friendly when your actually trying to make a program for useful purposes.<br>
the microsoft website gives me a line of coding with something to the effect of sndplaysnd but i'm confused as to what context that gets up in.. and i still cant point it to locate the wav file on the drive.<br>
I saw a few ideas on encrypting the wav file into a file on visual basic or something like that. But again no sucess when implementing the suggested way of proceeding.<br>
If anyone has any ideas or suggestions please feel free to try and help.. thanks alot..<br>
~Jason
-
Aug 13th, 2000, 12:19 PM
#2
Hyperactive Member
play a wav
This seems to work for me. just change the directory to a valid wav file.
Place this in a command button
Private Sub Command2_Click()
x = ("C:\windows\media\logoff.wav")
retval = sndPlaySound(x, SND_SYNC)
End Sub
in a module
Declare Function sndPlaySound Lib "winmm.dll" Alias "sndPlaySoundA" (ByVal lpszSoundName As String, ByVal uFlags As Long) As Long
Public Const SND_SYNC = &H0 ' play synchronously (default)
Matt 
-
Aug 13th, 2000, 12:21 PM
#3
As Megatron would say:
Keep in mind that sndPlaySound is superseded by PlaySound, hence it's obsolete.
Code:
Private Declare Function PlaySound Lib "winmm.dll" Alias "PlaySoundA" (ByVal lpszName As String, ByVal hModule As Long, ByVal dwFlags As Long) As Long
Private Sub Command1_Click()
'Play the WAV
PlaySound "C:\MyFile.wav", 0&, &H1
End Sub
-
Aug 13th, 2000, 12:23 PM
#4
Hyperactive Member
sorry the explaination....
This uses the API. Everything in the module I got from the API test viewer that comes with vb.Then I called the function, plugging in the values. X being the directory, uflags telling it to play it synchronously.
Matt 
-
Aug 13th, 2000, 12:24 PM
#5
Fanatic Member
PlaySound has a wider range of, well, gadgets.
See here for more info.
PS: That teacher of yours requires some <ahem> rigorous retraining.
[Edited by V(ery) Basic on 08-13-2000 at 01:27 PM]
-
Aug 13th, 2000, 05:48 PM
#6
Monday Morning Lunatic
However, PlaySound (I think) loads the whole file into memory, then plays it. So, check out the StreamFrom sample in the Platform SDK, which used DirectSound to stream a wave file from disk.
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|