Some test text!
Web / Guides / 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.
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',
},
});
});
Trial setup questions? Ask experts on Discord
Need other help? Contact Support
Pricing or product questions? Contact Sales