如何在iPhone sdk静音模式下播放声音文件?
如何在iPhone sdk静音模式下播放声音文件?
我正在尝试以静默模式播放声音文件,但结果为零,
我尝试过此代码
SystemSoundID soundID;
AudioServicesCreateSystemSoundID((CFURLRef)[NSURL fileURLWithPath:fullpath],&soundID);
AudioServicesPlaySystemSound (soundID);
当我在头文件中导入时,
#import <AudioToolbox/AudioToolbox.h>
创建类似
错误的错误:预期标识符在“\x786f7073”之前
尽快回答.....
提前致谢
关注
愚蠢的iPhone开发者
How to play Sound File In Silent Mode iPhone sdk ?
I m trying to play sound file in silent mode but result is zero
i have tried this code
SystemSoundID soundID;
AudioServicesCreateSystemSoundID((CFURLRef)[NSURL fileURLWithPath:fullpath],&soundID);
AudioServicesPlaySystemSound (soundID);
when i import in header file
#import <AudioToolbox/AudioToolbox.h>
create Error like
error: expected identifier before '\x786f7073'
Asnwer As Soon As Possible.....
Thanks In advance
Regard
StupidiPhoneDeveloper
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您必须定义一个不会被静音开关静音的音频会话类别。
查看苹果开发网站上的音频会话页面: http://developer.apple.com/library/ios/#documentation/Audio/Conceptual/AudioSessionProgrammingGuide/AudioSessionCategories/AudioSessionCategories.html%23//apple_ref/ doc/uid/TP40007875-CH4-SW1
也许 AVAudioSessionCategoryPlayAndRecord 就是您需要的。
you have to define an audio session category that is not silenced by the mute switch.
Check out the audio session page on apple dev site : http://developer.apple.com/library/ios/#documentation/Audio/Conceptual/AudioSessionProgrammingGuide/AudioSessionCategories/AudioSessionCategories.html%23//apple_ref/doc/uid/TP40007875-CH4-SW1
Maybe the AVAudioSessionCategoryPlayAndRecord is the one you need.
感谢好友这么快的回复
我找到了解决方案
通过以下代码,您可以检查您的iPhone配置文件(常规/静音)
这是代码
关于这个错误
只需在每个类头文件中写下一行
Thanks Buddy for such a quick reply
i have found the solution
By the following code you can check your iPhone Profile ( Regular/Silent)
and here is the code
And About this error
Just write below line in every class header file