AudioServicesPlaySystem声音振动有效但没有声音
AudioServicesPlaySystemSound 不执行任何操作,但 AudioServicesPlayAlertSound 会使 iPhone 振动。
AudioServicesCreateSystemSoundID 返回成功。我正在运行 iOS4 的 iPhone3G 上进行开发。
有什么想法吗? Peter
=====
以下是我如何创造声音:
NSString *sndPath = [[NSBundle mainBundle] pathForResource:@"first_touch" ofType:@"wav" inDirectory:@"/"];
CFURLRef sndURL = (CFURLRef)[[NSURL alloc] initFileURLWithPath:sndPath];
int e = AudioServicesCreateSystemSoundID(sndURL, &_firstTouch); // TODO: call 'AudioServicesDisposeSystemSoundID'
这就是我演奏它的人:
AudioServicesPlayAlertSound(_firstTouch);
AudioServicesPlaySystemSound doesn't do anything but AudioServicesPlayAlertSound makes the iPhone vibrate.
AudioServicesCreateSystemSoundID returns success. I'm developing on iPhone3G running iOS4.
Any ideas?
Peter
=====
Here's how I create the sound:
NSString *sndPath = [[NSBundle mainBundle] pathForResource:@"first_touch" ofType:@"wav" inDirectory:@"/"];
CFURLRef sndURL = (CFURLRef)[[NSURL alloc] initFileURLWithPath:sndPath];
int e = AudioServicesCreateSystemSoundID(sndURL, &_firstTouch); // TODO: call 'AudioServicesDisposeSystemSoundID'
And that's who I play it:
AudioServicesPlayAlertSound(_firstTouch);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
显示一些代码会有所帮助。
据猜测,您正在创建一个声音,播放该声音,然后立即删除该声音。这是行不通的;删除声音会导致其停止播放。
Showing some code helps.
At a guess, you're creating a sound, playing the sound, and then immediately deleting the sound. This doesn't work; deleting the sound causes it to stop playing.
我不会删除声音。我添加了源代码。
在我重新启动机器和 iPhone 后,它开始在模拟器上运行,但在 iPhone 上却无法运行。
它曾经在 iPhone 上运行过。我正在测试一个新项目,其中仅包含创建和播放声音。
I'm not deleting the sound. I added the source code.
After I rebooted both my machine and the iPhone, it started working on the simulator but not on the iPhone.
It worked once on the iPhone. I'm testing with a new project with just the create and play sound in it.