This is a multipart blog post:
Part 1: this post.
Part 2: Xamarin Android Bindings – Part 2
My yoga center is now closed because of the cover-19 crisis, but they’re running classes through Zoom. This is why I wanted to start experimenting Xamarin Android Bindings. I may be wrong but it seems to me that those bindings don’t exist yet in the open source community. I’ll be glad if I could contribute.
Harvesting the Zoom android SDK.
You can Download the Zoom Android SDK here. The SDK namespace starts with “us.zoom”.
Following the Xamarin tutorial to build a Bindings project, I ended up with a whopping total of 7508 build Errors and 2787 build warnings.
I was surprised by the name of the generated classes too. It seems that the Zoom SDK embed many dependencies that I do not need in my binding project.
So The first idea that came to my mind was to start small and iterate following my needs.
Generating a Metada.xml file
So the goal here is to get rid of everything that is not in the Zoom API surface.
The generated API.xml file on my first build would be parsed by a .net core 3.1 c# console program.
The code is below. It is very simple:
- Iterate over the API file looking for package XML nodes. I’m using this very handy helper method found here.
- If the package name does not start with “zoom.us”, create a remove-node element in the metadata.xml file. Documentation about customising the bindings could be found here.
using System.IO; using System.Xml; using System.Xml.Linq; namespace GenerateZoomBindingsMetadata { class Program { static void Main(string[] args) { using (XmlReader reader = XmlReader.Create(@"/Users/omatrot/Projects/ZoomBindings/ZoomBindings/obj/Debug/api.xml")) { using (FileStream fs = new FileStream(@"/Users/omatrot/Projects/ZoomBindings/ZoomBindings/Transforms/Metadata.xml", FileMode.Create)) { var settings = new XmlWriterSettings(); //settings.OmitXmlDeclaration = true; settings.Indent = true; //settings.NewLineOnAttributes = true; using (XmlWriter writer = XmlWriter.Create(fs, settings)) { //writer.Formatting = Formatting.Indented; writer.WriteStartDocument(); writer.WriteStartElement("metadata"); foreach (XElement element in reader.ElementsNamed("package")) { // Grab the package name string packageName = element.Attribute("name").Value; // add this package to a remove node in Metadata.Xml if (!packageName.StartsWith("us.zoom")) { writer.WriteStartElement("remove-node"); writer.WriteAttributeString("path", $@"/api/package[@name='{packageName}']"); writer.WriteEndElement(); } } writer.WriteEndElement(); writer.Flush(); } } } } } }
That seems to have worked pretty well as building the binding project now ends up with only 115 warnings 🙂
I’ll continue with this series until I’m able to connect to a room and display the video and hear the sound in a Xamarin Android Application.
Stay tuned.
Until next time, #stayathome.
One thought on “Xamarin Android Bindings – Part 1”