4

I successfully attach AVAudioPlayer nodes to my AVAudioEngine. However, I need to later check if these nodes have already been attached to it (so I don't re-add them).

Is there any certain property on the engine that I can check to see if its already been attached?

vikzilla
  • 3,998
  • 6
  • 36
  • 57

2 Answers2

1

You could check the engine property of the AVAudioPlayerNode and if nil this means it is not attached to an audio engine.

for playerNode in yourPlayerNodeArray {
        if playerNode.engine == nil {
            yourEngine.attach(playerNode)
        }
    }
Jess
  • 1,394
  • 12
  • 12
0

The implementation more than likely uses an interface implementation and has an API associated with it. I would suggest reading the API to check if a function exists that returns a list of (active) nodes attached.

Berni
  • 121
  • 1
  • 13
  • 1
    Yes I read the docs but didn't see anything helpful so am wondering if there are any other ways anybody knows – vikzilla Feb 20 '16 at 22:44
  • Create a **model** and store the a reference to the attached nodes. And create a static API for the **model** so that you can store and retrieve a reference to the nodes. – Berni Feb 20 '16 at 22:53