Setting up the JW Player Plugin with WIREWAX embedder SDK (Fandom Setup)
Last update: 2021-12-17 5:50PM EST
important
WIREWAX embedder SDK Fandom build is for Fandom Setup use only, please don't share the link to this doc to any non-Fandom domains.
important
JW Player Custom Plugin is a JavaScript script loaded by API embed JW Player. Please note that the latest JW Player version that supports custom plugin is v8.23.1
. On Dec 14, 2021 JW player released v8.24.0
, which impacts the custom plugin loading process. We are awaiting for JW player's new guidance on registering custom plugin in v8.24.0
, hence this guide is subject to change within the next a few weeks.
#
BriefThis guide is for use of the WIREWAX embedder SDK to build a custom Fandom plugin for JW player. In this article, we will cover a minimal implementation of a JW custom plugin, and some additional methods to enable WIREWAX interactions.
#
BasicsHere is a minimal use case of JW player API embed and the way to load a custom plugin:
For events binding, we will need to pass the JW player instance to plugin:
Then setup a new plugin script for implementation. The registering step is subject to change. Currently it will throw warning 305100
. It doesn't impact the plugin at this moment (v8.23.1
). Subject to update for latest v8.24.0 from JW Player.
#
Step by step guidanceThe overall steps for creating a WIREWAX powered JW Player plugin are:
- Valid interaction
- Setup or inject WIREWAX embedder SDK script (SDK script can be appended in head directly, however, not recommend doing so without any validating process)
- Resolve
JW media id
toWIREWAX vidId
- Initialize WIREWAX embedder and create WIREWAX video-less player
- Binding events
Depending on the use cases and client side setup, step 1~3 can switch to a different order.
Fandom use case is mostly JW player playlist, the following example is based on playlist usage, for more details and JW player event, please find the details here at JW player JavaScript API documentation.
#
Step 1 - on JW "playlistItem" event, validate interactionValidate interaction is a step to make sure WIREWAX interaction exists in the current video, normally by checking if a JW media id
is marked as interactivity enabled. Some clients has their own checking methods or endpoint to make sure the plugin won't load in non-interactive videos. In single interactive video or full interactive video playlist, this step is not necessary.
Since Fandom playlists are randomized mixed playlist, we highly recommend to validate if a playlist item has interaction first before injecting SDK.
An alternative way to validate interaction is to combine step 0 and step 2 together using the following utility method. If an error is thrown, we can assume this video is not interactive and skip:
Depending on playlist setup, JW media id can be found as mediaid
or videoId
:
#
Step 2 - Injecting embedder SDK on demandNext, once we have vidId
resolved, we need to inject the embedder SDK through a utility function within the plugin script. Embedder SDK can be setup outside of the plugin script in the page head, as long as the JW player video on this page has interaction:
- Fandom SDK url:
https://edge-assets-wirewax.wikia-services.com/creativeData/sdk-fandom/wirewax-embedder-sdk.js
#
Step 3 - Initialize embedder and video-less WIREWAX playerIn this step, we will:
- Create a container that matches JW Player media area to display WIREWAX interactive elements
- Initialize WIREWAX embedder and create video-less WIREWAX player
Embedder only need to be initialized once:
#
Step 4 - register time event to enable time sync in between WIREWAX player and JW PlayerWIREWAX powers client videos at frame level accuracy. Currently JW Player time event only supports as frequently as 10 times per second, which is below regular 24fps. In order to sync playback to frame level, a custom time update (timeline sync) handler need to set. There are a few ways to implement. In the following snippet, we will use requestAnimationFrame
:
#
Step 5 - setup other event handlersNext, we will setup other playback or interaction event handlers for custom usage, since the JW Player instance doesn't change on playlistItem event, this only needs to be done once.
#
Additional methodsOn playlist item change, sometimes the interaction from the previous video will persist. We've provided a dispose method to dispose the WIREWAX player.