Skip to content

VideoPreviewGenerator

roosit edited this page Nov 15, 2026 · 1 revision

VideoPreviewGenerator

Up | Previous | Next | Русский

Full source with short explanations

Below is the full source of the class in documentation form. The comments inside the block explain the purpose of the parts of the class, but they are not stored in the working file VideoPreviewGenerator.java: the production code stays clean and the explanations live in the wiki.

package com.velitask.plugin.official.previews;

import com.velitask.plugin.official.VelitaskPlagin;
import com.velitask.plugin.official.VideoIndicator;
import com.velitask.sdk.ISource;
import com.velitask.sdk.SourceType;
import com.velitask.sdk.preview.PreviewGenerator;
import com.velitask.sdk.preview.PreviewRequest;
import com.velitask.sdk.preview.PreviewTemplate;

/* Video preview generator: puts a single indicator layer on the thumbnail. */
public final class VideoPreviewGenerator extends PreviewGenerator {

    @Override
    /* Generator name, unique within the plugin. */
    public String getName() {
        return "video";
    }

    @Override
    /* Cheap check by source type; the source data is not read. */
    public boolean supports(ISource source) {
        return source.getType() == SourceType.VIDEO;
    }

    @Override
    /* Preview template: one indicator layer over the whole frame. */
    public PreviewTemplate generate(PreviewRequest request) {
        PreviewTemplate template = PreviewTemplate.create();
        template.layer(VelitaskPlagin.UID + "." + VideoIndicator.NAME).fill();
        return template;
    }

    @Override
    /* Baseline solution: another plugin can replace it with its own preview. */
    public boolean isBaseline() {
        return true;
    }
}

Purpose

Preview generator for video files. For every source of the "video" type it builds a thumbnail template from a single layer of the "Video" indicator.

How it works

Data. The generator does not read the source data. The supports(...) condition looks only at the source type (SourceType.VIDEO), so the check is cheap, as the PreviewGenerator contract requires.

Settings. The generator has no settings of its own, only the name "video". The generate(...) method does not use the PreviewRequest with the preview size: the template depends neither on the size nor on the source content.

Drawing. generate(...) creates a PreviewTemplate, adds a layer of the VideoIndicator indicator and calls fill() so that the layer takes the whole preview frame. The full layer name is assembled from the plugin identifier VelitaskPlagin.UID, a dot and VideoIndicator.NAME. No additional values are passed to the layer: the other indicator properties stay at their defaults. The picture itself is built by the application from this template.

The generator is registered in VelitaskPlagin.definePreviewGenerators(); the order there is: video, image, audio, geo. The application polls the generators of all plugins by the priority getPriority() (here the default value) and draws the first non-empty template.

Features and limitations

  • isBaseline() returns true: this is a baseline solution that other plugins can replace. With equal priority, the generator of a non-baseline plugin is asked first.
  • generate(...) never returns null, so once the generator has supported a source, the chain of generators goes no further.
  • Any source of the VIDEO type falls under this generator, including GoPro and DJI clips with telemetry inside: they get a video preview, not a map.
  • The class is final and public; no constructor is declared, the default constructor is used.

Clone this wiki locally