TypeError: Cannot read properties of undefined (reading 'document')

Product: WebViewer Audio

Product Version: WebViewer Audio 2.21.7
UI version ‘11.2.0’
Core version ‘11.2.0’
webviewer.min.js ‘11.2.0’
Build ‘1/8/2025|ad343a2ad’
WebViewer Server true
Full API false
UI ‘default’

Please give a brief summary of your issue: Implementing the webviewer video as a Custom PowerApps Component Framework control with React and TypeScript. The webviewer works well for pdf and other files but unable to load audio files using the video viewer.

Code:
WebViewer(
{
path: apryseFile.libPath,
//fullAPI: true,
licenseKey: apryseFile.apryseLicenceKey,
webviewerServerURL: apryseFile.serverURL,
extension: apryseFile.extension,
enableAnnotations: false,
enableRedaction: false,
streaming: false,
filename: apryseFile.fileName + ‘.’ + apryseFile.extension,
disabledElements: [
‘ribbons’,
‘notesPanel’,
‘notesPanelToggle’,
‘toolbarGroup-View’,
‘toolbarGroup-Annotate’,
‘toolbarGroup-Shapes’,
‘toolbarGroup-Insert’,
‘toolbarGroup-Edit’,
‘toolbarGroup-Forms’,
‘toolbarGroup-FillAndSign’
]
},
viewer.current,
).then(async (instance) => {
const { Core, UI } = instance;
Core.setWorkerPath(${apryseFile.libPath}/core/);//path that should point to the core folder in the WebViewer package.
const { documentViewer } = instance.Core;
//Set the View toolbar group as the default toolbar group
instance.UI.setToolbarGroup(‘toolbarGroup-View’);
// Extends WebViewer to allow loading media files (.mp3, .mp4, ogg, webm, etc.)
const {
loadAudio,
} = await initializeAudioViewer(
instance, {
// No need to provide license key when using in demo mode
//license: apryseFile.apryseLicenceKey,
});
console.log(‘Audio Viewer Initialized.’);
loadAudio(apryseFile.fileURL, { fileName: apryseFile.fileName + ‘.’ + apryseFile.extension });

    documentViewer.addEventListener("documentLoaded", () => {
      console.log('Audio Element Loaded');

    });
  });
1 Like

Hi Fiona,

In order to use Webviewer Audio or Video you will have to use the Iframe version of WebViewer.

You can do it easily switch from WebComponent to Iframe by doing:

WebViewer.Iframe({...})

Let me know if that works for you!

Best Regards,
Mickaël

1 Like