Sound not working in iPhone Simulator?

穿精又带淫゛_ 提交于 2019-11-26 06:32:02

问题


Somehow my iPhone Simulator is unable to play sounds. First an app I\'m working on using AudioServicesPlaySystemSound() stopped working.. I spent a while debugging this but sound is still working on the iPhone when I run the app on the device. I get the same results with other iPhone apps such as the sample Crash Landing app.

I can\'t find a sound setting anywhere in the simulator or Xcode preferences. I\'ve tried resetting the simulator through \"Reset Content and Settings\" menu item to no avail.


回答1:


On your Mac, go to System Preferences > Sound > Sound Effects and then uncheck and recheck "Play user interface sound effects".

You need to re-activate your system sounds, see the end of this page.




回答2:


I had no sound in the simulator, so I tested it with mobile safari and tried playing an mp3: No sound!

All the above tips didn't help. Eventually, I changed my INPUT source from the virtual soundflower device to Line-In, and the Simulator worked!

So, even if the app wasn't using input, it didn't work well with Soundflower.




回答3:


I've seen this problem after my update from OSX10.5.7 to 10.6.2

And I made the following changes to make the simulater sing again: Goto "Applications/Utilities" and run "Audio MIDI Setup", then change midi format from 48000 to 44100.




回答4:


OpenAL not working on the simulator was fixed with the 2.1 SDK. Make sure Active SDK and Active Executable are set to 2.1.

By the way, make sure you're using the last version of CrashLanding (v1.8). Some nasty leaks in SoundEngine were fixed recently.




回答5:


I've found sound to be very inconsistent in the simulator (2.1 SDK). Sometimes it works, sometimes it doesn't. Even when it does work, it's usually very choppy and distorted (when playing audio files such as mp3).

A few things to remember:

  • call AudioSessionInitialize as soon as your app finishes launching
  • set the kAudioSessionProperty_AudioCategory property for the session via AudioSessionSetProperty (with a value such as kAudioSessionCategory_MediaPlayback)
  • call AudioSessionSetActive(YES)

Of course when all else fails, just run it on your hardware!

EDIT: Now that the 2.2 SDK has been released, I haven't had any problems with sound in the simulator. They must have fixed the bugs! I highly recommend you upgrade to the 2.2 SDK.




回答6:


if reactivating system sounds didn't work for you try this: launch audio-midi-setup, then configure your "built in output" to use 44.100Hz, 2 channels, 24 bits. (from http://www.cocos2d-iphone.org/forum/topic/4159)

somehow after a few days, my iphone simulator now wants 48.000Hz, 2 channels, 24 bits. just play with it for a bit and be warned that it might change randomly when plugging in headphones, going to standby, restarting, etc.

and here's a an off-topic hint: when you plug headphones into your iphone/ipad the buffer size might double (e.g. from 512bytes to 1024 bytes), make sure you don't rely on the buffersize you requested!



来源:https://stackoverflow.com/questions/302399/sound-not-working-in-iphone-simulator

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!