Solved

Mediaplayer with WAV

Posted on 1997-10-19
2
216 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 100 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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

746 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now