DuckingMediaPlayer

This sample application demonstrates stream attenuation by implementing a media player that shows the default attenuation behavior provided by the system, opts out of ducking events, and implements custom handling when ducking events are received. This sample must be used in conjuction with DuckingCaptureSample. For more information about ducking or stream attenuation, see Default Ducking Experience.

This topic contains the following sections.

Description

This sample demonstrates the following features.

  • DirectShow to play a media file.
  • WASAPI for stream management and handling ducking events.

Requirements

Product Version
Windows SDK Windows 7
Visual Studio 2008

 

Downloading the Sample

This sample is available in the following locations.

Location Path/URL
Windows SDK \Program Files\Microsoft SDKs\Windows\v7.0\Samples\Multimedia\Audio\DuckingMediaPlayer\...

 

Building the Sample

To build the DuckingMediaPlayer sample, use the following steps:

  1. Open the DuckingMediaPlayer.sln in Visual Studio 2008.
  2. From within the window, select the Debug or Release solution configuration, select the Build menu from the menu bar, and select the Build option. If you do not open Visual Studio from the CMD shell for the SDK, Visual Studio will not have access to the SDK build environment. In that case, the sample will not build unless you explicitly set environment variable MSSdk, which is used in the project file, DuckingMediaPlayer.vcproj.

Running the Sample

If you build the application successfully, an executable file, DuckingMediaPlayer.exe, is generated. To run it, select Start Debugging or Start Without Debugging from the Debug menu or type DuckingMediaPlayer in a command window.

To view a demonstration of ducking, you must execute DuckingMediaPlayer and DuckingCaptureSample simultaneously. DuckingCaptureSample opens a communication stream and signals the system to generate a ducking event. The DuckingMediaPlayer is notified by the system when a ducking event occurs, and the media player performs the action requested by the user.

To disable ducking behavior:

  1. On the DuckingCaptureSample window, select Use default input device, and click Start to start a capture session from the communication device.
  2. On the DuckingMediaPlayer, select a media file to play, and specify the ducking option as Opt out of Ducking.

Notice that the media file is played without any interruption. The events generated by the system when the communication stream opened are ignored.

To demonstrate the default ducking behavior provided by the system, do the following:

  1. Select the Sounds option from the control panel. On the Communications tab, select Reduce the volume of other sounds by 80%.
  2. On the DuckingCaptureSample window, select Use default input device, and click Start to start a capture session from the communication device.
  3. On the DuckingMediaPlayer, select a media file to play, without choosing any of the ducking options.
  4. On the DuckingCaptureSample window, click Stop to stop the communication stream.

Notice that when DuckingCaptureSample opens the communication stream, the media file played by DuckingMediaPlayer plays without interruption, but the volume level is lowered. When the communication session is stopped, the volume is reset to the original setting. This stream attenuation behavior is the default ducking behavior implemented by the system.

To view a customized ducking behavior implemented by the media player:

  1. On the DuckingCaptureSample window, select Use default input device, and click Start to start a capture session from the communication device.
  2. On the DuckingMediaPlayer, select a media file to play, and specify the ducking option as Pause on Duck.
  3. On the DuckingCaptureSample window, click Stop to stop the communication stream.

Notice that when DuckingCaptureSample opens the communication stream, the media file played by DuckingMediaPlayer is paused. The playback resumes when the communication session is stopped. This stream attenuation behavior is the ducking behavior implemented by the media player.

DuckingMediaPlayer also demonstrates how to integrate volume control for each application with the volume mixer.

For more information about the stream attenuation feature, see Default Ducking Experience.

SDK Samples That Use the Core Audio APIs