Open banjerluke opened 2 years ago
Oh, hang on... looks like the AppDelegate object is exposed to the plugin (in CDVPlugin) after all. So you can access it with self.appDelegate()
in CordovaAudioKitPlugin.swift
.
Check out the dev/destroyable-audiomanager branch if you want, where I started down the path of making AudioManager something that can be instantiated and (eventually) destroyed on command.
All that annoying production-ready stuff we need to handle:
You mentioned making certain calls in
AppDelegate
.Keep in mind that we don't have access to that file from our Cordova plugin.See below.Cordova does have a few events it sends to plugins, which we might want to listen and respond to (stubs in CordovaAudioKitPlugin.swift):
About that last point. I'm planning to expose a setting in the app to choose an audio backend: AudioKit or Web Audio API (obviously with more user-friendly names). AudioKit will be opt-in at first, until I gather enough data to support making it opt-out. When the setting is changed, the WebView will be refreshed and the web page reloaded with whatever their preference is. Therefore, we don't want to instantiate any AudioKit objects until after the plugin calls
initialize
, and we want to be able to shut all the AudioKit-related stuff down if they refresh the page with Web Audio selected.