Windows Mobile 6 SndPlaySync 中 Mp3 播放缓慢
我正在尝试使用新支持的 mp3 播放功能 SndPlaySync (也尝试过 SndPlayAsync )从我的 winows 移动应用程序播放 mp3 文件。 我制作了最简单的程序,只是将函数附加到 WM_KEYDOWN 事件。 (下面附有代码)。但还是总有0.5-2秒的等待时间 该程序播放 mp3。当我简单地使用 PlaySound 并尝试播放 .wav 文件时,它会立即工作。我能做些什么?
代码:
这工作太慢
case WM_KEYDOWN:
PlaySound(c_szMid,NULL,NULL);
HSOUND hSound;
HRESULT hr;
SndOpen(c_szMid, &hSound);
hr = SndPlayAsync(hSound, 0);
hr = SndClose(hSound);
而这工作得很快:
case WM_KEYDOWN:
PlaySound(c_szMid,NULL,NULL);
将不胜感激任何想法!
谢谢!
担
I'm trying to play mp3 files from my winows mobile application using the newly supported mp3-playing function SndPlaySync ( also tried SndPlayAsync ).
I made the simplest program, just attached the function to a WM_KEYDOWN event. ( code attached below ). But stil there is always 0.5-2 seconds of wait before
the program plays the mp3. When i simply use PlaySound, and try to play a .wav file, it works instateneously. What can i do?
Code :
This works too slow
case WM_KEYDOWN:
PlaySound(c_szMid,NULL,NULL);
HSOUND hSound;
HRESULT hr;
SndOpen(c_szMid, &hSound);
hr = SndPlayAsync(hSound, 0);
hr = SndClose(hSound);
And this works fast :
case WM_KEYDOWN:
PlaySound(c_szMid,NULL,NULL);
Would be grateful for any ideas!
Thanks!
Dan
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
不要忘记
mp3
文件是经过压缩的,而wav
则不是。因此,延迟可能是将
mp3
文件读入内存并解压缩所需的时间,而wav
文件则不一定会发生这种情况。我不确定你如何验证这一点。
Don't forget that an
mp3
file is compressed, whereas awav
isn't.So the delay might be the time it takes to read the
mp3
file into memory and decompress it, which doesn't have to happen with thewav
file.I'm not sure how you'd verify this though.
这段代码对吗?现在,您调用 PlaySound(同步),然后调用异步版本。对我来说,应该播放声音两次。
另外,如果您尝试将 PlaySound 与 SND_ASYNC 标志一起使用,会发生什么行为你看?
Is that code right? Right now you call PlaySound (which is synchronous) followed by the async version. To me that should be playing the sound twice.
Also, if you try using PlaySound with the SND_ASYNC flag what behavior do you see?
我实际上在尝试 SndPlayAsync 的地方添加了代码,但它与 SndPlaySync 的工作原理相同。
我实际上缩小了问题范围 - 即使当我尝试使用播放 wav 文件时
PlaySound(带有 Sync 标志)并使用 SndPlaySync,SndPlaySync 运行速度慢两倍:(
我将提出一个关于它的新问题。
I actually added the code where i tried SndPlayAsync, but it worked the same with SndPlaySync.
I actually narrowed down the problem - Even When i try to play wav files using
PlaySound(with Sync flag) and using SndPlaySync, SndPlaySync runs twice as slow :(
I'll open a new question about it.