Some test text!

Loading...
Guides
Make your own UI

Create new UI for WebViewer Video

You can create a custom UI by using the video object. See the API here. With it you can access the underlying HTML5 video element and all its APIs. By setting renderControls in the videoOptions to false, we can disable the default Webviewer-Video controls. See the example code below.

import WebViewer from '@pdftron/webviewer';
import { initializeVideoViewer, renderControlsToDOM } from '@pdftron/webviewer-video';

WebViewer({
    path: '/webviewer/lib',
  },
  viewer.current,
).then(async instance => {
  // Extends WebViewer to allow loading HTML5 videos (.mp4, ogg, webm).
  const {
    getVideo,
    loadVideo,
  } = await initializeVideoViewer(
    instance,
    {
      license: '---- Insert commercial license key here after purchase ----',
    }
  );
  // Load a video at a specific url. Can be a local or public link
  // If local it needs to be relative to lib/ui/index.html.
  // Or at the root. (eg '/video.mp4')
  const videoUrl = 'https://pdftron.s3.amazonaws.com/downloads/pl/video/video.mp4';
  loadVideo(videoUrl);

  const docViewer = instance.Core.documentViewer;
  docViewer.addEventListener('videoElementLoaded', () => {
    const doc = docViewer.getDocument();
    const video = getVideo();
    const videoElement = video.getElement();
    ...
    ...
    const playButton = controls.querySelector('#playButton');

    playButton.addEventListener('click', () => {
      // play the video
      if (videoElement.paused || videoElement.ended) {
        videoElement.play();
      }
    });

    videoElement.addEventListener('timeupdate', async () => {
      const currentFrameNumber = video.getFrameFromTime(videoElement.currentTime);
      // do something with the frame number
    });
  });
});

Get the answers you need: Support

Upcoming Webinar: PDFTron SDK Tech Review | Nov 29, 2022 at 2 pm ET

PDFTron SDK

The Platform

NEW

© 2022 PDFTron Systems Inc. All rights reserved.

Privacy

Terms of Use