Skip to content

Using Player Across Multiple Platforms

One of the major benefits of adopting Player for rendering a UI is it’s ability to function across all the platforms Player supports (React, Android, iOS) using the same content. In order to facilitate this, and get the most out of Player’s architecture, here’s a few things to keep in mind as you integrate Player into multiple platforms.

Use Core Plugins to Share Functionality

One of the easiest, and most beneficial thing to do when integrating Player is to organize feature sets into plugins. Keeping each plugin small and concise allows for easy sharing of features with other Player integrations. Player Core, as well as each of the platform integration, supplies an interface for users to augment/extend the functionality of Player. This can be used to author validations, formatters, expressions, etc once, and be shared across Player implementations across platforms. As Player Core runs on every platform, any core Player plugin will also run on every platform which allows for shared functionality to be authored once and shared across every platform.

Plugins such as the common-types plugin is a great example of a plugin used to add a feature to Player in a reusable way. Since the validations, formats, and data-types present in this plugin are authored in Player Core, we eliminate the need to rewrite them to target each individual platform. Using this mechanism, we also guaranteed that the React, iOS, and Android Player configurations are able to process the same content in the same way across the systems. The most important usecase of this is the asset transforms. Writing the logic to transform the asset as authored in content to the UI representation in the shared transform layer moves repeated functionality to the shared layer decreasing the implementation complexity of each asset on every platform but still leaves room for rendering variability for each platform.

Use the meta-plugin to simplify plugin sets

In the previous example, two things were mentioned that may initially seem to contradict each other:

Keeping each plugin small and concise allows for easy sharing of features with other applications.

and

features/expressions/validations added in 1 are automatically present in the other platforms without any additional work.

If each plugin implements a single, small feature, how are we able to add new features to each platform without requiring additional work?

One pattern that we’ve found to work well is to continue to organize each feature into individual plugins/modules. This allows any application to opt-in to an individual feature, and makes sharing much, much simpler. In addition to this, we also create 1 more plugin using the meta-plugin to wrap all of the application’s feature requirements into 1 plugin. This allows additional plugins to to be added to the meta-plugin and each platform will still only require 1 plugin registered (which makes integration easy) while still allowing the individual pieces to be consumed if desired (which makes extensibility easy)