> For the complete documentation index, see [llms.txt](https://docs.apryse.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.apryse.com/web/video/integrate-audio.md).

# Integrate Webviewer Audio using JavaScript

Integrate Webviewer Audio using JavaScript with ease. Learn how to seamlessly incorporate audio features into your web application. Explore a step-by-step guide for successful integration. The Apryse

{% hint style="info" %}
New licenses for WebViewer Video are no longer offered.
{% endhint %}

![](https://3532544125-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FX9YnTSKIHvV7m0A36LbO%2Fuploads%2Fgit-blob-7a3d5c51ed2cf808d348f5a44b5002c16185dd6d%2Fb994a8c936c3057638b4049ae9cc1a5ce4d1186e-1284x866.png?alt=media)

## Initial setup

Before you begin, make sure your development environment includes [Node.js](https://nodejs.org/en/) and [npm](https://www.npmjs.com/get-npm/).

## Install

{% tabs %}
{% tab title="Shell" %}
{% code lineNumbers="true" %}

```sh
npm install @pdftron/webviewer-video
npm install @pdftron/webviewer-audio
```

{% endcode %}
{% endtab %}
{% endtabs %}

## How to use

Here is an example of how WebViewer, Webviewer-video and WebViewer-audio could be integrated into your application.

{% tabs %}
{% tab title="JavaScript" %}
{% code lineNumbers="true" %}

```js
import React, { useRef, useEffect } from 'react';
import WebViewer from '@pdftron/webviewer';
import { initializeVideoViewer } from '@pdftron/webviewer-video';
import {
  Waveform,
  initializeAudioViewer
} from '@pdftron/webviewer-audio';

const App = () => {
    const viewer = useRef(null);
    const videoUrl = 'https://pdftron.s3.amazonaws.com/downloads/pl/video/video.mp4';

    useEffect(() => {
      WebViewer(
        {
          path: '/webviewer/lib',
        },
        viewer.current,
      ).then(async instance => {
        await initializeAudioViewer(
          instance,
          { license },
        );

        // Extends WebViewer to allow loading media files (.mp3, .mp4, ogg, webm, etc.)
        const {
            loadVideo,
        } = await initializeVideoViewer(
            instance,
            {
                license: '---- Insert commercial license key here after purchase ----',
                AudioComponent: Waveform,
                cacheAudioWaveform: false,
            }
        );

        // 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')
        // A unique fileId should be generated for each url for audio caching to work properly
        loadVideo(videoUrl, { fileId: 'testId' });
      });
    }, []);

    return (
        <div className="App">
            <div className="webviewer" ref={viewer} />
        </div>
    );
}

export default App;
```

{% endcode %}
{% endtab %}
{% endtabs %}

Also see the [React sample](https://github.com/ApryseSDK/webviewer-video-sample/), for a complete solution, with further customizations.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.apryse.com/web/video/integrate-audio.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
