Thursday, October 8, 2026
HomeiOS Developmentios - Is there any solution to play a number of audio...

ios – Is there any solution to play a number of audio information at identical time? I am engaged on Piano app so I would like to do that all

[ad_1]

//Here is My Code >>>

import UIKit
import AVFoundation
import PianoKeyboard

class PianoViewController: UIViewController{

@IBOutlet weak var pianoKeyboard: PianoKeyboard!
@IBOutlet weak var fullMiniPianoView: UIView!

var participant: AVAudioPlayer?

override func viewDidLoad() {
    tremendous.viewDidLoad()
    pianoKeyboard.delegate = self
}


open override var supportedInterfaceOrientations: UIInterfaceOrientationMask{
    get {
        return .landscapeRight
    }
}

func playSound(fileName: String) {
    guard let path = Bundle.principal.path(forResource: fileName, ofType: "mp3") else {
        return }
    let url = URL(fileURLWithPath: path)
    do {
        participant = strive AVAudioPlayer(contentsOf: url)
        participant?.play()
    } catch let error {
        print(error.localizedDescription)
    }
}

}

extension PianoViewController: PianoKeyboardDelegate{

func pianoKeyUp(_ keyNumber: Int) {
    
}

func pianoKeyDown(_ keyNumber: Int) {
    playSound(fileName: "key" + String(format: "%02d", keyNumber+1))
}

}

[ad_2]

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments