本文介绍了iOS模拟器无法播放声音的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

在XCode 6上,一切都在设备上运行良好,但在模拟器上,声音不会播放。

On XCode 6, everything works well on device, but on simulator, sound is not played.

有我的快速代码:

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()

有日志:

ERROR:     98: Error '!obj' trying to fetch default input device's 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


推荐答案

发生错误是因为您试图从模拟器获取设备的采样率,这是不可能的。

The error occurs because you are trying to get device's sample rate from simulator, which is not possible.

所以有些硬件功能无法模拟它。

So some hardware functionality will not able to simulated with it.

它无法执行以下操作:


  1. 打开相机

  2. 播放声音

  3. 陀螺仪

  4. 加速度计

  5. 摇动效果

  6. 接收推送通知

  1. Open Camera
  2. Play sounds
  3. Gyrometer
  4. Accelerometer
  5. Shake effect
  6. Receive push notifications

还有更多需要设备硬件加速的产品。

And many more which required device hardware acceleration.

您需要在真实设备中对此进行测试。

这篇关于iOS模拟器无法播放声音的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-06 10:03