从C#开始偏移的时间播放WAV文件中的声音#

时间:2015-04-05 00:04:33

标签: c# wav audio-player soundplayer

我正在尝试协调播放声音,同时在同时录制的图表上显示其他一些数据。如果用户向前或向后拖动图表,我如何在WAV文件中向前或向后跳转以使声音仍然协调?我在SoundPlayer等API中看不到时间偏移。

2 个答案:

答案 0 :(得分:1)

似乎您无法使用SoundPlayer向后或向前跳过。

Windows Form: Play sound, but not from beginning

C# - Get time from soundplayer

答案 1 :(得分:1)

如果我正确理解了您的问题,请使用WMPLib.WindowsMediaPlayer,添加对" Windows Media Player"的引用从COM中,然后使用以下方法设置位置:

 WMPLib.WindowsMediaPlayer player = new  WMPLib.WindowsMediaPlayer();
 player.URL = file; //file to be played
 player.controls.play();
 player.controls.currentPosition = x; //set the position you want here when user drag

或者你可以使用naudio,free opensource API,从codeplex下载:

Naudio Library