Solved

Mediaplayer with WAV

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

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
ddeman not working in activex 3 103
Strange code, can use it, but i cant figure out what it does. 3 60
oracle global variables 4 68
Delphi: Connect to running MS Outlook 4 85
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…
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…
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.

773 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