> 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/open-video.md).

# Open Videos using JavaScript

Learn how to open videos in your web application using JavaScript with the @pdftron/webviewer-video package. Follow this guide to integrate video playback seamlessly into your web application. The Apr

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

{% embed url="<https://www.youtube.com/embed/xzvd9oN5Ngw>" %}

HTML5 Videos can be loaded into WebViewer with use of the [@pdftron/webviewer-video](https://www.npmjs.com/package/@pdftron/webviewer-video/) package.

### Install

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

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

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

Below is a sample setup of the video package with webviewer.

[`initializeVideoViewer`](https://sdk.apryse.com/api/video/module-@pdftron_webviewer-video.html#.initializeVideoViewer__anchor) is called to give WebViewer the ability to handle the loading of video files. Afterwards, a video can be loaded with `loadVideo`. Lastly settings to customize the behavior of the controls can be passed in when calling [`initializeVideoViewer`](https://sdk.apryse.com/api/video/module-@pdftron_webviewer-video.html#.initializeVideoViewer__anchor).

{% tabs %}
{% tab title="JavaScript (SDK v8.0+)" %}
{% code lineNumbers="true" %}

```js
import WebViewer from '@pdftron/webviewer';
import { initializeVideoViewer, renderControlsToDOM } from '@pdftron/webviewer-video';

WebViewer({
    path: '/webviewer/lib',
    selectAnnotationOnCreation: true,
  },
  viewer.current,
).then(async instance => {
  // Extends WebViewer to allow loading HTML5 videos (.mp4, ogg, webm).
  const {
      loadVideo,
  } = await initializeVideoViewer(
      instance,
      {
        license: '---- Insert commercial license key here after purchase ----',
      }
  );
  // 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);
});
```

{% endcode %}

[WebViewerInstance](https://sdk.apryse.com/api/web/WebViewerInstance.html) [initializeVideoViewer](https://sdk.apryse.com/api/video/module-@pdftron_webviewer-video.html#~initializeVideoViewer__anchor)
{% endtab %}

{% tab title="JavaScript (SDK v7.0+)" %}
{% code lineNumbers="true" %}

```js
import WebViewer from '@pdftron/webviewer';
import { initializeVideoViewer } from '@pdftron/webviewer-video';

WebViewer({
    path: '/webviewer/lib',
    selectAnnotationOnCreation: true,
  },
  viewer.current,
).then(async instance => {
  // Extends WebViewer to allow loading HTML5 videos (.mp4, ogg, webm).
  const {
    loadVideo,
  } = await initializeVideoViewer(
    instance,
    {
      license: '---- Insert commercial license key here after purchase ----',
    }
  );
  // 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);
});
```

{% endcode %}

[WebViewerInstance](https://sdk.apryse.com/api/web/WebViewerInstance.html) [initializeVideoViewer](https://sdk.apryse.com/api/video/module-@pdftron_webviewer-video.html#.initializeVideoViewer__anchor)
{% endtab %}
{% endtabs %}


---

# 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 dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

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

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
