Reputation: 107
How to pause all playing sounds (Windows media palyer or another palyer) to play a specific sound in my application and then return to play the previous paused sound.
That is, if you want a sound is being played on a sound player like windows media player, my program pause this sound to play a specific sound, and after finishing the specific sound to play back the sound was paused. Can someone help me?
My delphi version is 2010. Thanks.
Upvotes: 3
Views: 1308
Reputation: 107
Searching on google I found a windows xp application that does exactly what I need, it is called an IndieVolume per-application volume control (link here) for Windows XP. I'll test it and see how it works, in the worst case I have to do a workaround so you can do what I want. NO but if someone has a better idea, I'm always willing to listen, or rather read on ...
Upvotes: 0
Reputation: 24086
You did not specify which version of Windows you are targeting. It makes a big difference if you want to control audio per application.
In Windows 7, you can control the volume per application (well.. stream).
Applications that use ASIO cannot be controlled like this, but if you only care about Windows Media Player that shouldn't be a problem.
You can control the volume (or mute) of streams via the Core Audio API. IAudioEndpointVolume
or ISimpleAudioVolume
interfaces.
However, I would't recommend messing with mixer volumes.
Windows has a mechanism built in that does what you want. It's called ducking
or stream attenuation
, which is meant to lower/mute the volume of all non-communication audio streams when a "communication" stream starts.
In the Windows multimedia control panel (Mmsys.cpl) you can configure the default behavior via on the communications tab:
You'll have to find the default communication device, and play audio through that.
This unit here can help you to find it: http://code.google.com/p/mfpack-media-foundation/source/browse/trunk/MFPACK/CoreAudio/MMDeviceAPI/MMDeviceApi.pas
From here on I'm not 100% if ducking occurs automatically when you play audio or not. I didn't try it myself, but hopefully this guides you in the right direction. Let me know if you book any results.
ps: If I were you I'd look a bit deeper into mfpack, because it seems to be a useful library for this kind of stuff. I see that there are 3 comitters for that project (maxcmx, factoryx.code, and peter larson). I'm sure they can tell you how to accomplish your goal the right way.
Upvotes: 2