473,387 Members | 1,520 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

playing a sound using MMC, the second time no sound

133 100+
Hi guys,
I am playing a sound using MMC on a form that pops up. Ok here is the problem it plays fine the first time but when the form loads the second time
it plays no sound.


Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Load()
  2.     psSoundFile = "c:\alarm.wav"
  3.     MMControl1.DeviceType = "WAVEAUDIO"
  4.     MMControl1.FileName = psSoundFile
  5.  
  6.      CmdStop.Enabled = True
  7.         If MMControl1.Mode = mciModeNotOpen Then MMControl1.Command = "open"
  8.  
  9.         MMControl1.Command = "play"
  10. End Sub
  11.  
  12. Private Sub StopWav()
  13.     MMControl1.Command = "stop"
  14.     MMControl1.Command = "close"
  15.     MyMessage.Hide   
  16. End Sub
  17.  
  18. Private Sub CmdStop_Click()
  19.     StopWav
  20. End Sub
Thanks for any help guys
Gobble.
Feb 22 '08 #1
6 1921
debasisdas
8,127 Expert 4TB
What do you mean by when the form loads the second time
Feb 22 '08 #2
gobblegob
133 100+
What do you mean by when the form loads the second time
ok i' explain better, i have form1 and form2.
form2 is set to Show on a timer, and when it show's it plays a sound
problem is when this is repeated it play's no sound
Feb 22 '08 #3
debasisdas
8,127 Expert 4TB
Are you loading the form second time or just using Show and Hide methods ?
Feb 22 '08 #4
gobblegob
133 100+
Are you loading the form second time or just using Show and Hide methods ?
show method

well i want to keep Form1 running all the time
Feb 22 '08 #5
debasisdas
8,127 Expert 4TB
Then try running the code in Form_Activate event not in Load event.
Feb 22 '08 #6
gobblegob
133 100+
Then try running the code in Form_Activate event not in Load event.
Awesome mate it worked , i never even new about that event

Thanks heaps mate.

Gobble.
Feb 22 '08 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Brian Basquille | last post by:
Hello all, What is the syntax for simply playing a WAV file in your program? Am learning VB and have two VB books but don't wanna root through them to find the code. Any help would be much...
12
by: Marian Aldenhövel | last post by:
Hi, I am trying to make pygame play music on windows. This simple program: import pygame,time pygame.init() print "Mixer settings", pygame.mixer.get_init() print "Mixer channels",...
1
by: Peter Schmitz | last post by:
Hi, I'm just trying to play a *.wav file, making use of the unmanaged function "sndPlaySoundA" in winmm.dll, but I still got one question: How can I avoid, that the sound file itself has to be...
4
by: fAnSKyer/C# newbie | last post by:
I am using winmm.dll and I found that I can't just suspend it and resume it? What should I do? Any better idea? Should I use thread? and thread.suspend will work? Thanks
1
by: oops | last post by:
I've had no luck getting 2 sound files to start at the same time. the second one to start is delayed by about 3/4 of a second. Also would also prefer to start another clip a given point when one of...
6
by: =?Utf-8?B?VmVybm9uIFBlcHBlcnM=?= | last post by:
I have an application that is designed for using with a bar code scanner. I want the user to know that the scan was complete and the data was entered, so I am playing a system sound after data...
5
by: gazza67 | last post by:
Hi, Does anyone know how to check for when a sound has finished playing? I am currently using the SoundPlayer, there doesnt seem to be any event for this - am I missing something? Gary
3
by: thenath24 | last post by:
Hello all, I'm currently writing a 3D Game demo and i'm having trouble getting the program to play a sound and deal with a keystroke at the same time. If a sound is playing the program will...
3
by: Jack | last post by:
Hi, I'm writing a simple wav player (like winamp) and using the SoundPlayer class in c# 2005. Using winform buttons, I can begin playing the sound and stop half-way through the sound using:...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.