如何使用 Media Foundation 同时播放两种声音

How to play two sounds simultaneously using Media Foundation

我尝试使用 Media Foundation 同时播放多个声音。我创建了多个媒体会话并加载了多个 IMFMediaSources。但问题是在播放过程中不能再次使用 IMFMediaSource 。有没有更好的方法可以同时播放?多个音频或重复其中一个?

你能详细说明一下吗?

例如,您可以重新启动 IMFMediaSource 以重新播放它:

IMFMediaSource::Start :

Starts, seeks, or restarts the media source by specifying where to start playback.

或者您可以简单地停止源然后重新开始:

IMFMediaSource::Stop

When a media source is stopped, its current position reverts to zero. After that, if the Start method is called with VT_EMPTY for the starting position, playback starts from the beginning of the presentation.

PS : 我同意 Mgetz 的观点,如果你只播放简单的 wav 文件,XAudio2 是一个选项。告诉我们您的音频文件格式。