我有一个带有AVAudioPlayer的简单示例程序,并且在运行它时收到此消息。这在调用.play()
之前发生:
2019-10-08 12:34:53.093726 + 1100 PlayNotes2 [1587:137643] [plugin] AddInstanceForFactory:没有为id注册的工厂
F8BB1C28-BAE8-11D6-9C31-00039315CD46
程序运行正常,但我很担心收到此消息。
这是我完整的代码。带有playButtonTap
插座的视图上只有一个按钮。请注意,如果我对var audioPlayer
使用注释掉的声明,也会发生同样的事情。
import UIKit
import AVFoundation
class ViewController: UIViewController {
let soundFileName = "E_64kb"
// var audioPlayer = AVAudioPlayer()
var audioPlayer: AVAudioPlayer?
override func viewDidLoad() {
super.viewDidLoad()
let sound = Bundle.main.path(forResource: soundFileName, ofType: "mp3")
do {
audioPlayer = try AVAudioPlayer(contentsOf: URL(fileURLWithPath: sound!))
} catch {
print(error)
}
}
@IBAction func playButtonTap(_ sender: Any) {
audioPlayer!.play()
}
}
警告不重要。如果您确实反对它,请在设备上而不是在模拟器上运行该应用程序。控制台消息将消失。