Extending the Plugin
We are actively working to improve this documentation. The content you see here may be incomplete, subject to change, or may not fully reflect the current state of the feature. We appreciate your understanding as we continue to enhance our docs.
Most projects that use the background import feature need to implement a custom video importer that maps JW Player video data to the project's content model. This guide covers the key extension points.
Creating a Video Content Type​
Define a content type to store imported JW Player videos in Brightspot. At minimum, it needs a media ID field and an embedded JwPlayerVideo to hold the external video data:
1@Recordable.DisplayName("Video")2public class VideoExample extends Content {34@Required5@Indexed6private String mediaId;78@Embedded9@ToolUi.ReadOnly10private JwPlayerVideo jwPlayerVideo;1112@ToolUi.Hidden13private JwPlayerSettings jwPlayerSettings;1415public String getMediaId() {16return mediaId;17}1819public void setMediaId(String mediaId) {20this.mediaId = mediaId;21}2223public JwPlayerVideo getJwPlayerVideo() {24return jwPlayerVideo;25}2627public void setJwPlayerVideo(JwPlayerVideo jwPlayerVideo) {28this.jwPlayerVideo = jwPlayerVideo;29}3031public JwPlayerSettings getJwPlayerSettings() {32return jwPlayerSettings;33}3435public void setJwPlayerSettings(JwPlayerSettings jwPlayerSettings) {36this.jwPlayerSettings = jwPlayerSettings;37}3839@Override40public String getLabel() {41return Optional.ofNullable(jwPlayerVideo)42.map(JwPlayerVideo::getVideoTitle)43.orElse(mediaId);44}45}
The @Embedded JwPlayerVideo field stores the video metadata fetched from JW Player (title, description, thumbnail, duration, etc.). Marking it @ToolUi.ReadOnly prevents manual edits to the synced data.
Implementing a Video Importer​
Create a concrete implementation of AbstractJwPlayerVideoImporter to define how JW Player videos are imported into your content model. The doImport method receives a JwPlayerVideo and should return the local content object:
1public class VideoImporterExample extends AbstractJwPlayerVideoImporter<JwPlayerVideo, VideoExample> {23@Override4public VideoExample doImport(JwPlayerVideo videoItem) {5String mediaId = videoItem.getMediaId();67if (StringUtils.isBlank(mediaId)) {8return null;9}1011VideoExample video = Query.from(VideoExample.class)12.where("mediaId = ?", mediaId)13.first();1415if (video == null) {16video = new VideoExample();17video.setMediaId(mediaId);18}1920video.setJwPlayerVideo(videoItem);21video.setJwPlayerSettings(videoItem.getAccountSettings());2223setInitiatedByImport(video, true);24video.saveImmediately();2526return video;27}28}
Key points:
- Upsert pattern — Query for an existing record by media ID before creating a new one. This prevents duplicates when the same video is re-imported.
setInitiatedByImport— Call this before saving to flag the record as import-originated. Check this flag inbeforeSave/afterSavehooks if you need to skip logic that shouldn't run during import (such as syncing back to JW Player).- The plugin auto-discovers your importer class via
ClassFinder. If you have multiple implementations, specify which one to use with thevideo/jwplayer/importerClasssetting in your application context.
Implementing an External Item Converter​
To allow users to select a JW Player video from the search panel and create a local content record, implement an ExternalItemConverter:
1public class VideoConverterExample extends ExternalItemConverter<JwPlayerVideo, VideoExample> {23@Override4public Collection<? extends VideoExample> convert(JwPlayerVideo jwPlayerVideo) {5VideoExample video = new VideoExample();6video.setMediaId(jwPlayerVideo.getMediaId());7video.setJwPlayerVideo(jwPlayerVideo);8video.setJwPlayerSettings(jwPlayerVideo.getAccountSettings());9return Collections.singleton(video);10}11}
The converter is called when a user selects a JwPlayerVideo from the external item search results. It creates a new instance of your local content type, populates it with data from the JW Player video, and returns it for the user to edit and save.
Extension Points Reference​
| Class | Purpose |
|---|---|
AbstractJwPlayerVideoImporter | Map imported JW Player videos to your content model. Required for background import. |
ExternalItemConverter | Convert external JW Player videos to local content when selected from search. |
JwPlayerClient | Interface for the JW Player API client. Override to customize API behavior. |