我想在此方法中的块中重新加载我的表数据:
import UIKit
import AssetsLibrary
class AlbumsTableViewController: UITableViewController {
var albums:ALAssetsGroup[] = []
func loadAlbums(){
let library = IAAssetsLibraryDefaultInstance
library.enumerateGroupsWithTypes(ALAssetsGroupType(ALAssetsGroupAll),
usingBlock: {(group, stop) in
if group {
self.albums.append(group)
}
else {
dispatch_async(dispatch_get_main_queue(), {
self.tableView.reloadData()
})
}
}, failureBlock: { (error:NSError!) in println("Problem loading albums: \(error)") })
}
override func viewDidLoad() {
super.viewDidLoad()
loadAlbums()
// Uncomment the following line to preserve selection between presentations
// self.clearsSelectionOnViewWillAppear = false
// Uncomment the following line to display an Edit button in the navigation …Run Code Online (Sandbox Code Playgroud) 这是我在日志中看到的内容:
16:33:20.236: Call is Dialing
16:33:21.088: AVAudioSessionInterruptionNotification
16:33:21.450: AVAudioSessionRouteChangeNotification
16:33:21.450: ....change reason CategoryChange
16:33:21.539: AVAudioEngineConfigurationChangeNotification
16:33:21.542: Starting Audio Engine
16:33:23.863: AVAudioSessionRouteChangeNotification
16:33:23.863: ....change reason OldDeviceUnavailable
16:33:23.860 ERROR: [0x100a70000] AVAudioIONodeImpl.mm:317: ___ZN13AVAudioIOUnit11GetHWFormatEjPj_block_invoke: required condition is false: hwFormat
*** Terminating app due to uncaught exception 'com.apple.coreaudio.avfaudio', reason: 'required condition is false: hwFormat'
Run Code Online (Sandbox Code Playgroud)
我订阅了两个AVAudioEngineConfigurationChangeNotification,AVAudioSessionInterruptionNotification:
@objc private func handleAudioEngineConfigurationChangeNotification(notification: NSNotification) {
println2(notification.name)
makeEngineConnections()
startEngine()
}
@objc private func handleAudioSessionInterruptionNotification(notification: NSNotification) {
println2(notification.name)
if let interruptionType = AVAudioSessionInterruptionType(rawValue: notification.userInfo?[AVAudioSessionInterruptionTypeKey] as! UInt) { …Run Code Online (Sandbox Code Playgroud) 我正在使用一个SKAudioNode()在我的游戏中播放背景音乐.我有一个播放/暂停功能,一切正常,直到我插入耳机.根本没有声音,当我调用暂停/播放功能时,我收到此错误
AVAudioPlayerNode.mm:333:开始:必需条件为false:_engine-> IsRunning()com.apple.coreaudio.avfaudio',原因:'必需条件为false:_engine-> IsRunning()
有谁知道这意味着什么?
码:
import SpriteKit
class GameScene: SKScene {
let loop = SKAudioNode(fileNamed: "gameloop.mp3")
let play = SKAction.play()
let pause = SKAction.pause()
var isPlaying = Bool()
override func didMoveToView(view: SKView) {
loop.runAction(play)
isPlaying = true
self.addChild(loop)
}
override func touchesBegan(touches: Set<UITouch>, withEvent event: UIEvent?) {
_ = touches.first as UITouch!
for _ in touches {
if isPlaying {
loop.runAction(pause)
isPlaying = false
} else {
loop.runAction(play)
isPlaying = true
}
}
}
}
Run Code Online (Sandbox Code Playgroud) 我有一副带麦克风输入的蓝牙耳机。不使用麦克风,但使用时,输入和输出都强制为 8000kHz。
我的 AVAudioEngine 实例以 8000kHz 模式连接到耳机,除非我进入系统设置并指定我不想使用耳机进行输入(每次连接耳机时都必须执行此操作)。
我注意到其他应用程序可以以预期的 44100kHz 播放,没有任何问题。我的 AVAudioEngine 图中没有输入节点。
如何使 AVAudioEngine 更喜欢以合理的采样率进行连接?
swift ×3
ios ×2
audio ×1
avfoundation ×1
bluetooth ×1
ios8 ×1
macos ×1
skaudionode ×1
sprite-kit ×1
swift2 ×1