Some test text!

Loading...
Guides
Passing authentication headers to video HTTP requests

Passing authentication headers to video HTTP requests

WebViewer Video utilizes service workers to allow for custom headers to be passed onto HTTP requests that retrieve the video. This gives you the ability to authenticate videos on the server side and access them securely using WebViewer Video. See below example on how to utilize the service worker and pass custom headers.

Please note you will have to copy over the service worker file into your public folder. This can be done by using this script.

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 ----',
        `---- Other settings ----`,
      }
  );
  // 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, {
    headers: {
      Authorization: 'Bearer testToken',
      TestHeader: 'Test',
    },
  });
});

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