为什么在iPhone模拟器上单击按钮时没有声音提示?

时间:2018-11-12 17:44:48

标签: ios avfoundation avaudioengine

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)

无错误信息 项目根文件夹中的文件声音,项目子文件夹中的第二个副本 我试图点击按钮来播放音符

0 个答案:

没有答案