OSStatus error 2003334207 when using AVAudioPlayer

前端 未结 7 1367
野的像风
野的像风 2021-01-17 13:10

I am trying to play an MP3 file (works when played via VLC/iTunes) when a button is pressed. Here is my code:

     var audioPlayer: AVAudioPlayer!
     @IBAc         


        
7条回答
  •  刺人心
    刺人心 (楼主)
    2021-01-17 13:25

    As others have said, the audio player couldn't find the file.

    This helped me: Document directory path change when rebuild application

    Basically, you cannot load files with an absolute reference, as the sandbox environment regenerates the absolute file url each time. So you will need to add a small bit of code (see above) to get the correct urls to use.

提交回复
热议问题