Friday, December 2, 2022
HomeIOS Developmentios - How I can play audio file after downloaded

ios – How I can play audio file after downloaded


I’ve core library to obtain audio from server and save in native. But it surely do not have file extension.
When i attempt to load the audio file from file path URL, it all the time to get error at catch half.

it solely occurs when downloading mp3 recordsdata. For m4a it is working.
What flawed 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 {
      attempt AVAudioSession.sharedInstance().setCategory(.playback)
      attempt AVAudioSession.sharedInstance().setActive(true)
      
      participant = attempt AVAudioPlayer(contentsOf: url)
      if participant != nil {
        isPlayerConfigured = true
        participant?.delegate = self
        participant?.prepareToPlay()
      } else {
        isPlayerConfigured = false
        isPlaying = false
      }
    } catch(let error) {
      isPlayerConfigured = false
      isPlaying = false
      loge(error.localizedDescription)
    }
  }

Thanks in your serving to.

Attempt to load audio file at native with out extension file

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments