0

I have core library to download audio from server and save in local. But it don't have file extension.
When i try to load the audio file from file path URL, it always to get error at catch part.

it only happens when downloading mp3 files. For m4a it's working.
What wrong i do?

Error:

3531:  MP4Parser_PacketProvider->GetASBD() failed
101:  OpenFromDataSource failed
76:  Open failed

The code i used to load audio at bellow

  func setupPlayer(url: URL) {
    do {
      try AVAudioSession.sharedInstance().setCategory(.playback)
      try AVAudioSession.sharedInstance().setActive(true)
      
      player = try AVAudioPlayer(contentsOf: url)
      if player != nil {
        isPlayerConfigured = true
        player?.delegate = self
        player?.prepareToPlay()
      } else {
        isPlayerConfigured = false
        isPlaying = false
      }
    } catch(let error) {
      isPlayerConfigured = false
      isPlaying = false
      loge(error.localizedDescription)
    }
  }

Thanks for your helping.

Try to load audio file at local without extension file

0 Answers0