切换到iOS 5后无法播放系统声音 [英] Couldn't play system sound after switching to iOS 5

查看:180
本文介绍了切换到iOS 5后无法播放系统声音的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我在 iOS 4 中播放哔音效果:

This is how I played a beep sound effect in iOS 4:

SystemSoundId beepOnSoundId;

CFURLRef soundUrl = CFBundleCopyResourceURL(
    CFBundleGetMainBundle(), 
    CFSTR("beep"), 
    CFSTR("wav"), 
    NULL
);

// soundUrl logged:
// file://localhost/var/mobile/Applications/ ... beep.wav

AudioServicesCreateSystemSoundID(soundUrl, &beepOnSoundId);

// beepOnSoundId logged: 4097

AudioServicesPlaySystemSound(beepOnSoundId);

当我将设备升级到 iOS 5 时,它停止工作。我什么也听不到。

It stopped working, when I upgraded my device to iOS 5. I hear nothing. I logged out all the variables and none were nil or 0.

iOS 5 中API的更改如何破坏我的声音播放代码?

How has the API changed in iOS 5 that breaks my sound playing code?

问题可能是因为我有一个 AVCaptureSession 运行时,我播放声音。 iOS 5不知何故不让你这样做。

The problem may be because I have an AVCaptureSession running while I play the sound. iOS 5 somehow doesn't let you do this anymore. I need to play a beep sound while I am recording something from the camera.

推荐答案

bug report 可能与您的问题相关,如果您有AVCaptureSession正在运行。

This bug report could be related to your question, if you have an AVCaptureSession running.


在iOS 5下,当使用AudioServicesPlaySystemSound调用时,如果有一个音频设备
处于活动状态的AVCaptureSession,
将不会工作。

Under iOS 5, when using an AudioServicesPlaySystemSound call, it will not work when there is an active AVCaptureSession with an audio device active.

这篇关于切换到iOS 5后无法播放系统声音的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆