IOS Simulator does not play sound

On XCode 6, everything works well on device, but no sound plays on the simulator.

There is my quick code:

var url =  NSURL(string: "http://my.url.com/sound.mp3")
var data = NSData(contentsOfURL: url!)
// Removed deprecated use of AVAudioSessionDelegate protocol
AVAudioSession.sharedInstance().setCategory(AVAudioSessionCategoryPlayback, error: nil)
AVAudioSession.sharedInstance().setActive(true, error: nil)
self.player = AVAudioPlayer(data: data, error: nil)
self.player.prepareToPlay()
self.player.delegate = self
self.player.volume = 1
self.player.play()

      

There is a magazine:

ERROR:     98: Error '!obj' trying to fetch default input device sample rate

ERROR:     100: Error getting audio input device sample rate: '!obj'

WARNING:   230: The input device is 0x0; '(null)'

WARNING:   234: The output device is 0x26; 'AppleHDAEngineOutputDP:3,0,1,1:0:{2D4C-092D-00000000}'

ERROR:     400: error '!obj'

ERROR:     113: * * * NULL AQIONode object

ERROR:     180: EXCEPTION thrown ('!dev'): -

ERROR:     703: Can't make UISound Renderer

ERROR:     >aqsrv> 70: Exception caught in (null) - error -1

ERROR:     180: EXCEPTION thrown ('!dev'): -

ERROR:     >aqsrv> 70: Exception caught in (null) - error -1

      

+3


source to share


2 answers


The error comes from what you are trying to get device sample rate

from the simulator, which is not possible.

Because the simulator is not hardware. Its software.

Thus, some hardware functions will not be able to simulate with it.

He cannot do the following:



  • Open the camera
  • Playing sounds
  • gyrometer
  • Accelerometer
  • Shaking effect
  • Receive push notifications

And much more that requires hardware acceleration of the device.

You need to test this on a real device.

+1


source


I had this problem, comment from @Matti Jokipii helped me a lot.

You must have audio input enabled so your Mac won't give you a null exception.
Go to System Preferences> Sound. And check that you have an input. If not, you will need to add a microphone and re-launch the app.



enter image description here

+3


source







All Articles