Windows Mobile 6.5 SndPlayAsync - C# 包装器?
我正在 Windows Mobile 6.5 上实现 mp3 播放。我需要使用 SndPlayAsync API 函数,因为我不想在播放文件之前阻止调用线程(SndPlaySync 会阻止直到音频文件正在播放)。不幸的是,SndPlayAsync 方法采用声音句柄而不是声音文件路径作为参数,因此需要在播放之前打开句柄并在播放后释放它。问题是我在这个 API 中没有任何关于播放完成的信息。有人使用 C# 包装器来实现这个 API 吗?我在哪里可以买到一个?我查过 OPENNETCF 但他们似乎不支持这个 API。
问候
I'm implementing mp3 playback on Windows Mobile 6.5. I need to use SndPlayAsync API function since I don't want to block calling thread until the file is played (SndPlaySync blocks until the audio file is playing). Unfortunately the SndPlayAsync method takes sound handle instead of sound file path as parameter so there's a need to open the handle before and release of it after playback. The problem is that I don't have any information about the playback completion in this API. Did anybody use a C# wrapper for this API? Where can I get one? I've looked up OPENNETCF but they seem not to support this API.
Regards
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您必须先调用 SndOpen 才能获取句柄。查看文档,声明将是这样的:
所以你可以使用类似这样的东西来调用它:
You have to call SndOpen first to get the handle. Looking at the docs, the declarations would be something along these lines:
So you'd use something like this to call it:
如果您使用 .NET CF,则无需创建包装器,只需使用 System.Media.SoundPlayer 类来处理它。有几个选项,包括 PlaySync,它将同步播放声音。
例如:
如果您不想阻塞 UI 线程,也可以将其放在单独的线程中。
If you are using .NET CF there is no reason to create a wrapper, you can just use the System.Media.SoundPlayer class to handle it. There are several options including PlaySync which will play the sound synchronously.
For instance:
You can also put it in a separate thread if you don't want to block the UI thread.
您可以使用 SndGetWaitHandle 获取将发出信号的事件的句柄当声音播放完毕时。您可以使用 WaitForSingleObject API 来等待或测试事件是否已设置。
You can use SndGetWaitHandle to get a handle to an event which will be signaled when the sound is finished playing. You can use the WaitForSingleObject API to wait or test if the event has been set.