5

I am facing problem to play audio in iOS 12.2 simulator, while same code is working fine with iOS 14.3. I have checked SO and searched over apple forum found that same type issue was happening with iOS 14 but it's resolved now.

Thanks in Advance.

My Sample Code:

class ViewController: UIViewController {
    
    var audioPlayer:AVPlayer?
    var playerItem:AVPlayerItem?
    
    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view.
    }
    @IBAction func playMusic() {
        playAudioFromURL()
    }
    
    private func playAudioFromURL() {
           guard let url = URL(string: "https://s3.amazonaws.com/kargopolov/kukushka.mp3") else {
               print("error to get the mp3 file")
               return
           }
           do {
               audioPlayer = try AVPlayer(url: url as URL)
           } catch {
               print("audio file error")
           }
           audioPlayer?.play()
       }
}

Error Message while running on iOS 12.2

2021-01-27 16:51:56.773138+0530 SimpleAvplyar[12446:281352] [AudioHAL_Client] HALB_IOBufferManager.cpp:226:GetIOBuffer: HALB_IOBufferManager::GetIOBuffer: the stream index is out of range 2021-01-27 16:51:56.773472+0530 SimpleAvplyar[12446:281352] [AudioHAL_Client] HALB_IOBufferManager.cpp:226:GetIOBuffer: HALB_IOBufferManager::GetIOBuffer: the stream index is out of range 2021-01-27 16:51:56.786532+0530 SimpleAvplyar[12446:281352] [aqme] 254: AQDefaultDevice (1): output stream 0: null buffer 2021-01-27 16:51:56.786880+0530 SimpleAvplyar[12446:281352] [aqme] 1640: EXCEPTION thrown (-50): - 2021-01-27 16:52:11.024274+0530 SimpleAvplyar[12446:281260] [aqme] 177: timed out after 15.000s (0 1); suspension count=0 (IOSuspensions: ) 2021-01-27 16:52:11.025729+0530 SimpleAvplyar[12446:281260] 239: CA_UISoundClientBase::StartPlaying: AddRunningClient failed (status = -66681). 2021-01-27 16:52:11.785607+0530 SimpleAvplyar[12446:281516] [AudioHAL_Client] HALB_IOBufferManager.cpp:226:GetIOBuffer: HALB_IOBufferManager::GetIOBuffer: the stream index is out of range 2021-01-27 16:52:11.785796+0530 SimpleAvplyar[12446:281516] [AudioHAL_Client] HALB_IOBufferManager.cpp:226:GetIOBuffer: HALB_IOBufferManager::GetIOBuffer: the stream index is out of range 2021-01-27 16:52:11.802351+0530 SimpleAvplyar[12446:281516] [aqme] 254: AQDefaultDevice (1): output stream 0: null buffer 2021-01-27 16:52:11.802589+0530 SimpleAvplyar[12446:281516] [aqme] 1640: EXCEPTION thrown (-50): -

kalpa
  • 884
  • 1
  • 15
  • 22

0 Answers0