import type { WebViewerInstance } from '@pdftron/webviewer'; export declare type AudioViewerOptions = { license?: string; showMobileStyling?: boolean; generatedPeaks?: Array; isDemoMode?: boolean; cacheAudioWaveform?: boolean; enableRedaction?: boolean; }; export declare type LoadAudioOptions = { fileName?: string; generatedPeaks?: Array; serviceWorkerLocation?: string; headers?: any; }; export declare type WebViewerAudioUINamespace = { updateElement: (dataElement: string, props: any) => void; }; export declare type WebViewerAudioInstance = { loadAudio: (url: string | Blob | File, options?: LoadAudioOptions) => void; getFileURL: (instance: WebViewerInstance) => string; getWaveSurfer: (instance: WebViewerInstance) => any; UI: WebViewerAudioUINamespace; Waveform: any; }; /** * UI namespace of WebViewer Audio * @namespace UI * @example * WebViewer(...) .then(function(instance) { const license = '---- Insert commercial license key here after purchase ----'; const audioInstance = await initializeAudioViewer( instance, { license, }, ); audioInstance.UI.updateElement('regionDeleteButton', { onClick: () => console.log('do something') }); }); */ /** * Update an WebViewer Audio element in the viewer. Valid options are 'redactApplyButton' and 'regionDeleteButton'. * @method UI.updateElement * @param {string} dataElement - the data element of the element that will be updated. * @param {object} props - an object that is used to override an existing item's properties. * @returns {void} */ /** * This is an addon for WebViewer that allows loading media files (.mp3, .mp4, .ogg, .webm, etc.) so that the audio track can be annotated. * See the npm package on {@link https://www.npmjs.com/package/@pdftron/webviewer-audio @pdftron/webviewer-audio} for more information. * @module @pdftron/webviewer-audio */ /** * Event emitted when ffmpeg is loaded * * @event audioViewerLoaded * @example WebViewer(...) .then(function(instance) { const { docViewer } = instance; docViewer.on('audioViewerLoaded', listener); }); */ /** * Event emitted when an annotation observer is attached * * @event audioViewerEventsAttached * @example WebViewer(...) .then(function(instance) { const { docViewer } = instance; docViewer.on('audioViewerEventsAttached', listener); }); */ /** * Event emitted when audio is loaded, decoded and the waveform drawn * * @event audioViewerReady * @example WebViewer(...) .then(function(instance) { const { docViewer } = instance; docViewer.on('audioViewerReady', listener); }); */ /** * Event emitted when audio begins playing * * @event audioPlay * @example WebViewer(...) .then(function(instance) { const { docViewer } = instance; docViewer.on('audioPlay', listener); }); */ /** * Event emitted when audio gets paused * * @event audioPause * @example WebViewer(...) .then(function(instance) { const { docViewer } = instance; docViewer.on('audioPause', listener); }); */ /** * Loads an audio file for the WebViewer instance passed into initializeAudioViewer. * @callback loadAudio * @param {String | Blob | file} url - The audio url, Blob object, or File object. * @param {Object} options Optional options object * @param {string} [options.fileName] Name of the file. URLs without an extension need this property set * @param {Array} [options.generatedPeaks=null] An array of peaks to render the waveform * @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.headers] Custom headers to attach when making http requests to provided url * Large files can freeze the browser so use this as a workaround. Safari has a known issue when this option is turned on. * Some files will not seek correctly on Safari. * @returns {void} * @example WebViewer(...) .then(function(instance) { const license = '---- Insert commercial license key here after purchase ----'; const { loadAudio, } = await initializeVideoViewer(instance, { license }); loadAudio('https://www.mydomain.com/my_video_or_audio_url'); }); * @example WebViewer(...) .then(function(instance) { const license = '---- Insert commercial license key here after purchase ----'; const { loadAudio, } = await initializeVideoViewer(instance, { license }); loadAudio('https://www.mydomain.com/my_video_or_audio_url', { headers: { 'Authorization': 'Basic YWxhZGRpbjpvcGVuc2VzYW1l' }, }); }); */ /** * Can only be used in licensed mode. In the demo mode it will only return `null`. * Returns the file URL loaded through `loadAudio` until redactions are made. After * redactions are made the URL will be a Data URL for the modified file. * @callback getFileURL * @returns {void} * @example WebViewer(...) .then(function(instance) { const license = '---- Insert commercial license key here after purchase ----'; const { getFileURL, loadAudio, } = await initializeVideoViewer(instance, { license }); ... ... // Download the file const anchor = document.createElement('a'); anchor.href = getFileURL(); anchor.target = "_blank"; anchor.download = myAudioFile.mp3; // Auto click on a element, trigger the file download anchor.click(); }); */ /** * @typedef {Object} AudioFunctions * @property {function} loadAudio * Loads an audio file for the WebViewer instance passed into initializeAudioViewer. * First param is the audio/video url. * @property {function} getFileURL * Can only be used in licensed mode. In the demo mode it will only return `null`. * Returns the file URL loaded through `loadAudio` until redactions are made. After * redactions are made the URL will be a Data URL for the modified file. * @property {UI} UI * The UI namespace of WebViewer Audio, used to update UI elements of WebViewer Audio. * @example WebViewer(...) .then(function(instance) { const license = '---- Insert commercial license key here after purchase ----'; const audioInstance = await initializeAudioViewer( instance, { license, }, ); const { loadAudio, getFileURL } = audioInstance; audioInstance.UI.updateElement('regionDeleteButton', { onClick: () => console.log('do something') }); loadAudio('https://www.mydomain.com/my_audio_url'); instance.Core.docViewer.on('documentLoaded', async () => { // Download the file const anchor = document.createElement('a'); anchor.href = getFileURL(); anchor.target = "_blank"; anchor.download = myAudioFile.mp3; // Auto click on a element, trigger the file download anchor.click(); }); }); */ declare const initializeWebViewerSettings: (instance: WebViewerInstance) => void; /** * Initializes the audio viewer so that WebViewer can load media files. * @alias module:@pdftron/webviewer-audio.initializeAudioViewer * @param {Object} instance The WebViewer instance * @param {Object} options Options object. * @param {string} [options.license=''] The WebViewer Audio license. * @param {boolean} [options.showMobileStyling=true] Whether to show styling for mobile devices. * @param {Array} [options.generatedPeaks=null] An array of peaks to render the waveform * @param {Object} [options.enableRedaction] Enables Redaction tools. Requires a server component to run ffmpeg commands. See: https://www.pdftron.com/documentation/web/guides/video/server-component/ * @returns {AudioFunctions} A promise that resolves to an object containing the functions needed to load videos in WebViewer. * @example WebViewer(...) .then(function(instance) { const license = '---- Insert commercial license key here after purchase ----'; const { loadAudio, getFileURL, } = await initializeAudioViewer( instance, { license, showMobileStyling: true, }, ); }); */ declare const initializeAudioViewer: (instance: WebViewerInstance, options: AudioViewerOptions) => Promise; declare const unmountWebViewerAudio: (instance: any, root: any) => void; export { initializeAudioViewer, unmountWebViewerAudio, initializeWebViewerSettings, };