Solved

Mediaplayer with WAV

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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
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 a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

751 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