FilterDemoFramework.SimplePlayEngine.SimplePlayEngine C# (CSharp) Method

SimplePlayEngine() public method

public SimplePlayEngine ( System.Action componentsFoundCallback = null ) : System
componentsFoundCallback System.Action
return System
		public SimplePlayEngine (Action componentsFoundCallback = null)
		{
			PresetList = new AUAudioUnitPreset [0];
			this.componentsFoundCallback = componentsFoundCallback;
			engine.AttachNode (player);

			var fileUrl = NSBundle.MainBundle.GetUrlForResource ("drumLoop", "caf");
			if (fileUrl == null)
				throw new NullReferenceException ("drumploop.caf file not found");

			SetPlayerFile (fileUrl);

			if (componentsFoundCallback != null) {
				UpdateEffectsList ();
				AUAudioUnit.Notifications.ObserveAudioComponentRegistrationsChanged ((sender, e) => UpdateEffectsList ());
			}

			var error = AVAudioSession.SharedInstance ().SetCategory (AVAudioSessionCategory.Playback);
			if (error != null)
				throw new NSErrorException(error);

			AUAudioUnit.Notifications.ObserveAudioComponentInstanceInvalidation ((sender, e) => {
				var crashedAU = e.Notification.Object as AUAudioUnit;
				if (AudioUnit == crashedAU)
					SelectEffectWithComponentDescription (null, null);
			});
		}