gpt4 book ai didi

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

转载 作者:太空宇宙 更新时间:2023-11-03 10:32:30 25 4
gpt4 key购买 nike

我正在尝试协调播放声音与在同时记录的图表上显示一些其他数据。如果用户向前或向后拖动图形,我怎样才能在 WAV 文件中向前或向后跳过以使声音仍然协调?我在 SoundPlayer 这样的 API 中看不到时间偏移量.

最佳答案

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

 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,免费的开源 API,从 codeplex 下载:

Naudio Library

关于c# - 在 C# 中从开始的时间偏移播放 WAV 文件中的声音,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29452741/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com