import UIKit
import AVFoundation
class KeyboardViewController: UIInputViewController {
@IBAction func SoundPlay(_ sender: UIButton) {
let engine = AVAudioEngine()
let sampler=AVAudioUnitSampler()
engine.attach(sampler)
engine.connect(sampler, to:engine.mainMixerNode,format: nil)
do{
try engine.start()
if let url=Bundle.main.url (forResource:"healin01",withExtension:"wav")
{
try sampler.loadAudioFiles(at:[url])
}
}
catch
{print("Couldnt")}
sampler.startNote(36, withVelocity: 90, onChannel: 0)
无错误信息 项目根文件夹中的文件声音,项目子文件夹中的第二个副本 我试图点击按钮来播放音符