21

Working on a project in swift, where I'm trying to initiate the AVPlayer, and for some reason it trows me an exception saying

AudioHardware.cpp:1200:AudioObjectRemovePropertyListener: AudioObjectRemovePropertyListener: no object with given ID 0.

I guess the issue is with my URL. Here is my code

func initPlayer() {
    let url:NSURL = NSURL(string:"https://purelight1-163000.appspot.com/api/user/v2/media/track/60/sample")!
    self.playerItem = AVPlayerItem(url: url as URL)
    self.player=AVPlayer(playerItem: self.playerItem!)
    let playerLayer=AVPlayerLayer(player: self.player!)
    playerLayer.frame = CGRect(x: 0, y: 0, width: 10, height: 50) // actually this player layer is not visible
    self.view.layer.addSublayer(playerLayer)
}
Inder Kumar Rathore
  • 39,458
  • 17
  • 135
  • 184
danu
  • 1,079
  • 5
  • 16
  • 48
  • This has something to do with the simulator, I think. I am not getting the errors on a real device. – Suragch Dec 18 '17 at 07:53
  • 2
    Unrelated, but why create an `NSURL` and then cast it to `URL`? You should just simply do `let url= URL(string:"https://purelight1-163000.appspot.com/api/user/v2/media/track/60/sample")!` – Dávid Pásztor Dec 24 '17 at 14:20
  • 2
    Do you happen to have a breakpoint set for All Exceptions? The solution for me was to set this to only catch Objective-C exceptions and not C++ ones by editing the breakpoint. – kylejs Dec 26 '17 at 11:05
  • yes break points set for All Exceptions sir. however technically it should not crash – danu Dec 28 '17 at 05:07
  • I ended up here looking for a different error, but the message was the same `no device with given ID`. This seems to only happen to me when I'm using the Simulator as @Suragch said. I was able to get it to stop by selecting my Simulator window, then going to `Hardware -> Audio Output` and changing it off of the system default (Note: this might still be the same output source) – zwilf Jun 24 '19 at 13:39

3 Answers3

3

For me it was because of the Simulator's audio output.

I was using an audio capture app iShowU for different project with headphones setup. But to disable the simulator's audio only I set that "Audio Device Output" to the iShowU setup with the headphones (which weren't plugged in). It finished playing the video that was loaded and then that problem appeared.

Switching the audio output from Simulator > I/O > Audio Output to the System one and rerunning my build resolved my issue.

spasbil
  • 239
  • 1
  • 12
0

That issue happens because of the simulator.

I had the same issue with the iPhone 14 simulator and I solved it selecting System as audio output and tapping on Device --> Erase All Content And Settings...

-2

Xcode is overly chatty. You just need edit your Scheme (Product > Scheme > Edit Scheme) and create a new Environment Variable OS_ACTIVITY_MODE and set its value to disable.

Jeroen
  • 53
  • 1
  • 3
  • 8
    I'm not sure this approach is ideal. Won't this silence other important (or at least potentially important) warnings? – Joe Susnick May 24 '18 at 20:56
  • 2
    @AmitaiB This answer is not meant to solve the problem, just to stop the console from writing so many lines. Useful if you want to see only your print outputs – Shaked Sayag Oct 11 '18 at 20:04
  • 15
    I would advise against any of my developers doing this. This also suppresses constraint violations. – Jereme May 28 '19 at 21:15