Did you find this guide helpful?
Some test text!
Web / Guides / Make your own UI
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: Chat with us