|
-
Nov 19th, 2000, 08:55 PM
#1
Thread Starter
New Member
Just a quick question, how can I play a wave file in a visual basxic program without needing a command button. Say i wanted to play a wave file on a Got_Focus() event, how could I go about doing so?
-
Nov 20th, 2000, 03:44 AM
#2
Hyperactive Member
playing wave files' E Z.
if you're not using Windows 2000, do this:
(Multimedia Control ain't work'n with 2000)
steps:
right-click toolbox.
select Microsoft MultiMedia Control 6.0
(or 5.0, if you have VB 5.0)
click OK.
here's de code:
(inside your module that contains the object that is
going to receive focus)
Option Explicit
Private Sub WhatEver_GotFocus()
MMControl1.DeviceType = "WaveAudio"
MMControl1.FileName = "C:\WINNT\MEDIA\TADA.wav"
MMControl1.Command = "open"
MMControl1.Command = "play"
End Sub
There is an alternative. You can use
the Windows Media Player ActiveX control, or you can write
lots of assembly code inside C++ to make your own ActiveX
control that plays media files.
[Edited by jovton on 11-20-2000 at 03:48 AM]
-
Nov 20th, 2000, 10:17 PM
#3
Thread Starter
New Member
:p Thanx alot.
Thanks man, that helped out alot..
-
Nov 21st, 2000, 02:23 AM
#4
Hyperactive Member
hey, Divide_0verride!
saw my signature? i love to help out newbies! and, i am
a newbie myself. but i do have some experience in vb and
c++, and yes, even vc++ programming. some pascal and
delhpi too! man, i'd love to learn some assembly language!
anyway, it was nice help'n ya.
-
Nov 21st, 2000, 06:42 PM
#5
Frenzied Member
I don't think you actually need a control to play wav files, you can use the PlaySound API.
In a module:
Code:
Private Declare Function PlaySound Lib "winmm.dll" Alias "PlaySoundA" ( _
ByVal lpszName As String, _
ByVal hModule As Long, _
ByVal dwFlags As Long _
) As Long
In your code:
Code:
PlaySound "C:\WINNT\MEDIA\TADA.wav", 0, 0
Harry.
"From one thing, know ten thousand things."
-
Nov 25th, 2000, 06:49 PM
#6
Thread Starter
New Member
Thanks
thanks alot both of you... it's been a great help.. my project is nearing it's completion date, and it is crunch time.. laters
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
|