Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Mediaplayer with WAV

Posted on 1997-10-19
2
Medium Priority
?
229 Views
Last Modified: 2010-04-04
Hi,

I'm writing a program that uses several different sounds (.WAV), each time the user clicks on a drawgrid a sound should play. I've done this by using 1 MediaPlayer. Because
there are several different sounds I always set the filename property of the MediaPlayer to the correct sound, then open and play it. This works, but is slow. A user might
click several times on the drawgrid and may only hear one sound instead of several different sounds. I don't want the user to wait for a sound to end before he can click again.

So essentially how do I keep the sounds in memory for faster playing and how can I play more than one sound at once or stop the previous sound and play an new one ?

Thanks,
Michael.
0
Comment
Question by:michaelsanders
2 Comments
 
LVL 5

Accepted Solution

by:
JimBob091197 earned 400 total points
ID: 1348150
Hi Michael

Unless you need to use MediaPlayer, rather use the PlaySound API call.  (Add MmSystem to your "uses" clause.)

To play a sound, and wait for it to finish:
PlaySound('C:\Temp\ASound.wav', 0, SND_APPLICATION or SND_FILENAME);

To play a sound, and return immediately:
PlaySound('C:\Temp\ASound.wav', 0, SND_APPLICATION or SND_FILENAME or SND_ASYNC);

The 2nd example would probably suit your purposes.  As soon as you start playing a new sound, the previous one is stopped.

Hope this helps you.
JB
0
 
LVL 1

Author Comment

by:michaelsanders
ID: 1348151
Thanks!
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
Suggested Courses

824 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question