> 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/custom-ui.md).

# Create new UI for WebViewer Video

Create a custom UI for WebViewer Video by accessing the HTML5 video element and APIs. Disable default controls with renderControls for a tailored viewing experience. Explore the API and example code.

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

You can create a custom UI by using the video object. See the [video API](https://sdk.apryse.com/api/video/) for more. With it you can access the underlying HTML5 video element and all its [APIs](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/video/). By setting `renderControls` in the [`videoOptions`](https://sdk.apryse.com/api/video/module-@pdftron_webviewer-video.html#.initializeVideoViewer__anchor) to `false`, we can disable the default Webviewer-Video controls. See the example code below.

{% 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',
  },
  viewer.current,
).then(async instance => {
  // Extends WebViewer to allow loading HTML5 videos (.mp4, ogg, webm).
  const {
    getVideo,
    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);

  const docViewer = instance.Core.documentViewer;
  docViewer.addEventListener('videoElementLoaded', () => {
    const doc = docViewer.getDocument();
    const video = getVideo();
    const videoElement = video.getElement();
    ...
    ...
    const playButton = controls.querySelector('#playButton');

    playButton.addEventListener('click', () => {
      // play the video
      if (videoElement.paused || videoElement.ended) {
        videoElement.play();
      }
    });

    videoElement.addEventListener('timeupdate', async () => {
      const currentFrameNumber = video.getFrameFromTime(videoElement.currentTime);
      // do something with the frame number
    });
  });
});
```

{% 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, renderControlsToDOM } from '@pdftron/webviewer-video';

WebViewer({
    path: '/webviewer/lib',
  },
  viewer.current,
).then(async instance => {
  // Extends WebViewer to allow loading HTML5 videos (.mp4, ogg, webm).
  const {
    getVideo,
    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);

  instance.docViewer.on('videoElementLoaded', () => {
    const doc = docViewer.getDocument();
    const video = getVideo();
    const videoElement = video.getElement();
    ...
    ...
    const playButton = controls.querySelector('#playButton');

    playButton.addEventListener('click', () => {
      // play the video
      if (videoElement.paused || videoElement.ended) {
        videoElement.play();
      }
    });

    videoElement.addEventListener('timeupdate', async () => {
      const currentFrameNumber = video.getFrameFromTime(videoElement.currentTime);
      // do something with the frame number
    });
  });
});
```

{% 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/custom-ui.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.
