Solved

Mediaplayer with WAV

Posted on 1997-10-19
2
226 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
Suggested Courses
Course of the Month3 days, 17 hours left to enroll

630 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