import type { WebViewerInstance } from '@pdftron/webviewer'; import type { WebViewerVideo } from './api/Video/index'; export declare type LoadVideoOptions = { fileName?: string; headers?: any; serviceWorkerLocation?: string; withCredentials?: boolean; generatedPeaks?: Array; useShakaPlayer?: boolean; fps?: number; }; export declare type WebViewerVideoUINamespace = { updateElement: (dataElement: string, props: any) => void; enableCompareMode: () => void; loadCompareVideoA: (url: string | Blob | File, options?: LoadVideoOptions) => Promise; loadCompareVideoB: (url: string | Blob | File, options?: LoadVideoOptions) => Promise; disableCompareMode: () => void; getFrames: (framesToGet: Array) => Promise; }; export declare type VideoViewerOptions = { license?: string; showFrames?: boolean; showTooltipPreview?: boolean; renderControls?: boolean; AudioComponent?: any; cacheAudioWaveform?: boolean; defaultLoadAudio?: boolean; showFullscreenButton?: boolean; showSubtitlesButton?: boolean; showAnnotationPreview?: boolean; openNotesPanelOnDocumentLoaded?: boolean; libPath?: string; showMobileStyling?: boolean; showFrameNumbersByDefault?: boolean; }; export declare type WebViewerVideoInstance = { getVideo: () => WebViewerVideo; renderControlsToDOM: (container: HTMLElement) => void; loadVideo: (url: string | Blob | File, options?: LoadVideoOptions) => Promise; setVideoWatermark: (instance: any, docViewer: any, iframeWindow: any) => void; dangerouslySetNoteTransformFunction: (handler: Function) => void; UI: WebViewerVideoUINamespace; }; declare const renderControlsToDOM: (instance: any, container: any, options: any) => import("react-dom/client").Root; declare const initializeWebViewerSettings: (instance: WebViewerInstance) => void; /** * UI namespace of WebViewer Video * @namespace UI * @example * WebViewer(...) .then(function(instance) { const license = '---- Insert commercial license key here after purchase ----'; const videoInstance = await initializeVideoViewer( instance, { license, }, ); videoInstance.UI.updateElement('redactApplyButton', { onClick: (redactAnnotations) => { // custom code here } }); }); */ /** * This is an addon for WebViewer that allows loading HTML5 videos (.mp4, ogg, webm) so that their video frames can be annotated. * See the npm package on {@link https://www.npmjs.com/package/@pdftron/webviewer-video @pdftron/webviewer-video} for more information. * @module @pdftron/webviewer-video */ /** * Event emitted when video begins playing * * @event videoPlay * @example WebViewer(...) .then(function(instance) { const { docViewer } = instance; docViewer.addEventListener('videoPlay', listener); }); */ /** * Event emitted when video gets paused * * @event videoPause * @example WebViewer(...) .then(function(instance) { const { docViewer } = instance; docViewer.addEventListener('videoPause', listener); }); */ /** * Event emitted when video element gets initialized * * @event videoElementLoaded * @example WebViewer(...) .then(function(instance) { const { docViewer } = instance; docViewer.addEventListener('videoElementLoaded', listener); }); */ /** * Returns the instance of {@link Video} associated with the document. * This needs to be called after the 'videoElementLoaded' event. See {@link event:videoElementLoaded} * @callback getVideo * @returns {object} The instance of {@link Video} associated with the document. */ /** * Loads a video for the WebViewer instance passed into initializeVideoViewer. * @callback loadVideo * @param {string | Blob | File} url The video url or video file or video blob * @param {Object} options Optional options object * @param {string} [options.fileName] Name of the file. URLs without an extension need this property set * @param {Object} [options.headers] Custom headers to attach when making http requests to provided URL * @param {string} [options.serviceWorkerLocation=''] The folder location of your service worker. The service worker is used to pass * custom headers to the requested media. You may need to specify where in which folder this file is located on your server if it is * not at the root level. * @param {Object} [options.withCredentials=false] CORS requests for this element will have the credentials flag set to 'include' * @param {Array} [options.generatedPeaks=null] An array of pre-generated peaks for corresponding video file * @param {boolean} [options.useShakaPlayer=true] Runs shaka player integration instead of HTML video * @param {number} [options.fps=null] Sets the frames per second of the video. Usually retrieved automatically, but this option may * be used incase that fails. * @returns {void} * @example WebViewer(...) .then(function(instance) { const license = '---- Insert commercial license key here after purchase ----'; const { loadVideo, } = await initializeVideoViewer(instance, { license }); loadVideo('https://www.mydomain.com/my_video_url'); }); * @example WebViewer(...) .then(function(instance) { const license = '---- Insert commercial license key here after purchase ----'; const { loadVideo, } = await initializeVideoViewer(instance, { license }); loadVideo('https://www.mydomain.com/my_video_url', { headers: { 'Authorization': 'Basic YWxhZGRpbjpvcGVuc2VzYW1l' }, serviceWorkerLocation: '/', }); }); */ /** * Mounts the react component for the video controls into the passed in container. * Useful when renderControls is set to false and you want to render them somewhere else. * @callback renderControlsToDOM * @param {Object} customContainer - A container element, e.g. a div. * @returns {void} * @example WebViewer(...) .then(function(instance) { const license = '---- Insert commercial license key here after purchase ----'; const { loadVideo renderControlsToDOM, } = await initializeVideoViewer( instance, { license, renderControls: false, }, ); ... instance.Core.documentViewer.addEventListener'documentLoaded', (e) => { const customContainer = instance.UI.iframeWindow.document.querySelector('.custom-container'); renderControlsToDOM(customContainer); }); }); */ /** * Accepts a function that will be called every time a note in the left panel is rendered. * This function can be used to add, edit or hide the contents of the note. Use this function instead of * the webviewer one. The webviewer one will be overwritten by video. See WebViewer documentation {@link https://docs.apryse.com/api/web/UI.html#.dangerouslySetNoteTransformFunction dangerouslySetNoteTransformFunction}. * @callback dangerouslySetNoteTransformFunction * @param {NoteTransformFunction} noteTransformFunction The function that will be used to transform notes in the left panel. See {@link https://docs.apryse.com/api/web/UI.html#.NoteTransformFunction NoteTransformFunction}. * @returns {void} * @example WebViewer(...) .then(function(instance) { const videoInstance = await initializeVideoViewer(instance, { license }); videoInstance.dangerouslySetNoteTransformFunction((wrapper, state, createElement) => { // Change the title of every note wrapper.querySelector('.author-and-time>span').innerHTML = 'My custom note title'; // Add a button that alerts the user when clicked const button = createElement('button'); button.onmousedown = (e) => { if(state.isSelected) { alert('Hello world!'); } else { alert('Goodbye world!'); } }; button.innerHTML = 'Alert me' wrapper.appendChild(button); // Add a button that makes the annotation blue const button = createElement('button'); button.onmousedown = (e) => { state.annotation.StrokeColor = new instance.Core.Annotations.Color(0, 0, 255); instance.UI.annotManager.redrawAnnotation(state.annotation) }; button.innerHTML = 'Make me blue' wrapper.appendChild(button); }); }); */ /** * @typedef {Object} VideoFunctions * @property {getVideo} getVideo * Returns the instance of {@link Video} associated with the document. * @property {loadVideo} loadVideo * Loads a video for the WebViewer instance passed into initializeVideoViewer. * @property {renderControlsToDOM} renderControlsToDOM * Mounts the react component for the video controls into the passed in container. * Useful when renderControls is set to false and you want to render the controls somewhere else. * @property {dangerouslySetNoteTransformFunction} dangerouslySetNoteTransformFunction * Accepts a function that will be called every time a note in the left panel is rendered. * This function can be used to add, edit or hide the contents of the note. Use this function instead of * the webviewer one. The webviewer one will be overwritten by video. See WebViewer documentation {@link https://docs.apryse.com/api/web/UI.html#.dangerouslySetNoteTransformFunctionapi/web/UI.html#.dangerouslySetNoteTransformFunction dangerouslySetNoteTransformFunction}. * @property {UI} UI * The UI namespace of WebViewer Video, used to update UI elements of WebViewer Video. */ /** * Initializes the video viewer so that webviewer can load videos. * @alias module:@pdftron/webviewer-video.initializeVideoViewer * @param {Object} instance The WebViewer instance * @param {Object} options Options object. * @param {number} documentViewerNumber The document viewer number * @param {string} [options.license=''] The WebViewer Video license or file url. * @param {boolean} [options.showFrames=true] Shows or hides video timeline reel. * @param {boolean} [options.showTooltipPreview=true] Shows or hides tooltip preview. * @param {boolean} [options.renderControls=true] Shows or hides the video controls. * @param {React.Component} [options.AudioComponent=null] The Webviewer-Audio component * @param {boolean} [options.cacheAudioWaveform=true] Caches audio waveform on initial load * @param {boolean} [options.defaultLoadAudio=true] Loads audio on initial load * @param {boolean} [options.showFullscreenButton=true] Shows or hides the fullscreen button on the video * @param {boolean} [options.showSubtitlesButton=true] Shows or hides the subtitles button on the video controls * @param {boolean} [options.showAspectRatioGuideButton=true] Shows or hides the aspect ratio guide button on the video controls * @param {boolean} [options.showPlaybackSpeedButton=true] Shows or hides the playback speed button on the video controls * @param {boolean} [options.showAnnotationPreview=true] Created annotations will have a preview in the notes panel. Turned on by default for Chromium browsers. Off for other browsers due to preview being, often, of the incorrect frame. * @param {boolean} [options.openNotesPanelOnDocumentLoaded=true] Notes panel will be open on document loaded * @param {boolean} [options.showMobileStyling=false] Shows or hides mobile styling * @param {Object} [options.libPath] The path to the video lib files. Only ffprobe files for now. * @param {boolean} [options.showFrameNumbersByDefault=false] Shows frame numbering by default on the video controls * * @returns {VideoFunctions} A promise that resolves to an object containing the functions needed to load videos in WebViewer. */ declare const initializeVideoViewer: (instance: WebViewerInstance, options: VideoViewerOptions, documentViewerNumber?: number) => Promise; export { renderControlsToDOM, initializeVideoViewer, initializeWebViewerSettings, };