I've implemented this mod Can I add a music library to the Xcode iOS Simulator? to play music in the Xcode Simulator using the MediaPlayer Framework. This mod works great! My app can play the songs in a PlayList, extract MetaData, and play songs.
I’ve recently switched the app from MPMediaPlayer to AVFoundation’s AVAudioPlayer. It works great when Xcode side loading on a physical device, but fails in the Xcode Simulator.
I’m using MPMediaPickerController to select music. I capture the MPMediaItem collection returned. I can extract MetaData from the current MPMediaItem, but get the following error when attempting to create an AVAudioPlayer with the MPMediaItem’s assetURL.
ERROR instantiating AVAudioPlayer: The operation couldn’t be completed. (OSStatus error 1768973119.)
Pertinent code:
let path: NSURL = item.assetURL as NSURL?
let avAudioPlayer = AVAudioPlayer(contentsOf: path as URL)
The MPMediaItem’s assetURL prints as
Optional(ipod-library://item/item.m4a?id=8845257749286139209)
The path: NSURL prints as
pod-library://item/item.m4a?id=8845257749286139209
Has anyone gotten the AVFoundation player to play music in the Xcode Simulator? (Again MediaPlayer player works fine.)