Skip to main content

Extending the Plugin

🚧Documentation Under Construction

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")
2
public class VideoExample extends Content {
3
4
@Required
5
@Indexed
6
private String mediaId;
7
8
@Embedded
9
@ToolUi.ReadOnly
10
private JwPlayerVideo jwPlayerVideo;
11
12
@ToolUi.Hidden
13
private JwPlayerSettings jwPlayerSettings;
14
15
public String getMediaId() {
16
return mediaId;
17
}
18
19
public void setMediaId(String mediaId) {
20
this.mediaId = mediaId;
21
}
22
23
public JwPlayerVideo getJwPlayerVideo() {
24
return jwPlayerVideo;
25
}
26
27
public void setJwPlayerVideo(JwPlayerVideo jwPlayerVideo) {
28
this.jwPlayerVideo = jwPlayerVideo;
29
}
30
31
public JwPlayerSettings getJwPlayerSettings() {
32
return jwPlayerSettings;
33
}
34
35
public void setJwPlayerSettings(JwPlayerSettings jwPlayerSettings) {
36
this.jwPlayerSettings = jwPlayerSettings;
37
}
38
39
@Override
40
public String getLabel() {
41
return 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:

1
public class VideoImporterExample extends AbstractJwPlayerVideoImporter<JwPlayerVideo, VideoExample> {
2
3
@Override
4
public VideoExample doImport(JwPlayerVideo videoItem) {
5
String mediaId = videoItem.getMediaId();
6
7
if (StringUtils.isBlank(mediaId)) {
8
return null;
9
}
10
11
VideoExample video = Query.from(VideoExample.class)
12
.where("mediaId = ?", mediaId)
13
.first();
14
15
if (video == null) {
16
video = new VideoExample();
17
video.setMediaId(mediaId);
18
}
19
20
video.setJwPlayerVideo(videoItem);
21
video.setJwPlayerSettings(videoItem.getAccountSettings());
22
23
setInitiatedByImport(video, true);
24
video.saveImmediately();
25
26
return 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 in beforeSave/afterSave hooks 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 the video/jwplayer/importerClass setting 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:

1
public class VideoConverterExample extends ExternalItemConverter<JwPlayerVideo, VideoExample> {
2
3
@Override
4
public Collection<? extends VideoExample> convert(JwPlayerVideo jwPlayerVideo) {
5
VideoExample video = new VideoExample();
6
video.setMediaId(jwPlayerVideo.getMediaId());
7
video.setJwPlayerVideo(jwPlayerVideo);
8
video.setJwPlayerSettings(jwPlayerVideo.getAccountSettings());
9
return 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​

ClassPurpose
AbstractJwPlayerVideoImporterMap imported JW Player videos to your content model. Required for background import.
ExternalItemConverterConvert external JW Player videos to local content when selected from search.
JwPlayerClientInterface for the JW Player API client. Override to customize API behavior.