@pdftron/webviewer-video
Version:
This is an addon for WebViewer that allows loading HTML5 videos (.mp4, ogg, webm) so that their video frames can be annotated.
1,732 lines (658 loc) • 26.3 kB
HTML
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>Documentation Namespace: UI</title>
<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<link type="text/css" rel="stylesheet" href="styles/sunlight.default.css">
<link type="text/css" rel="stylesheet" href="styles/site.simplex.css">
</head>
<body>
<div class="navbar navbar-default navbar-fixed-top ">
<div class="container">
<div class="navbar-header">
<a class="navbar-brand" href="index.html">Documentation</a>
<button class="navbar-toggle" type="button" data-toggle="collapse" data-target="#topNavigation">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
</div>
<div class="navbar-collapse collapse" id="topNavigation">
<ul class="nav navbar-nav">
<li class="dropdown">
<a href="namespaces.list.html" class="dropdown-toggle" data-toggle="dropdown">Namespaces<b class="caret"></b></a>
<ul class="dropdown-menu ">
<li><a href="UI.html">UI</a></li>
</ul>
</li>
<li class="dropdown">
<a href="modules.list.html" class="dropdown-toggle" data-toggle="dropdown">Modules<b class="caret"></b></a>
<ul class="dropdown-menu ">
<li><a href="module-@pdftron_webviewer-video.html">@pdftron/webviewer-video</a></li>
</ul>
</li>
<li class="dropdown">
<a href="classes.list.html" class="dropdown-toggle" data-toggle="dropdown">Classes<b class="caret"></b></a>
<ul class="dropdown-menu ">
<li><a href="Video.html">Video</a></li>
</ul>
</li>
<li class="dropdown">
<a href="events.list.html" class="dropdown-toggle" data-toggle="dropdown">Events<b class="caret"></b></a>
<ul class="dropdown-menu ">
<li><a href="module-@pdftron_webviewer-video.html#~event:videoElementLoaded">event:videoElementLoaded</a></li><li><a href="module-@pdftron_webviewer-video.html#~event:videoPause">event:videoPause</a></li><li><a href="module-@pdftron_webviewer-video.html#~event:videoPlay">event:videoPlay</a></li>
</ul>
</li>
<li class="dropdown">
<a href="global.html" class="dropdown-toggle" data-toggle="dropdown">Global<b class="caret"></b></a>
<ul class="dropdown-menu ">
<li><a href="global.html#waitForEvents">waitForEvents</a></li>
</ul>
</li>
</ul>
<div class="col-sm-3 col-md-3">
<form class="navbar-form" role="search">
<div class="input-group">
<input type="text" class="form-control" placeholder="Search" name="q" id="search-input">
<div class="input-group-btn">
<button class="btn btn-default" id="search-submit"><i class="glyphicon glyphicon-search"></i></button>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
<div class="container" id="toc-content">
<div class="row">
<div class="col-md-8">
<div id="main">
<h1 class="page-title">Namespace: UI</h1>
<section>
<header>
<h2>
UI
</h2>
</header>
<article>
<div class="container-overview">
<div class="description">UI namespace of WebViewer Video</div>
<dl class="details">
</dl>
<h3>Example</h3>
<pre class="sunlight-highlight-javascript">WebViewer(...)
.then(function(instance) {
const license = '---- Insert commercial license key here after purchase ----';
const videoInstance = await initializeVideoViewer(
instance,
{
license,
},
);
videoInstance.UI.updateElement('redactApplyButton', {
onClick: (redactAnnotations) => {
// custom code here
}
});
});</pre>
</div>
<h3 class="subsection-title">Methods</h3>
<dl>
<hr>
<dt>
<h4 class="name" id=".enableCompareMode"><span class="type-signature"><static> </span>enableCompareMode()</h4>
</dt>
<dd>
<div class="description">
Enables frame by frame comparison of videos
</div>
<dl class="details">
</dl>
<h5>Returns:</h5>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">void</span>
</dd>
</dl>
<h5>Example</h5>
<pre class="sunlight-highlight-javascript">WebViewer(...)
.then(function(instance) {
const license = '---- Insert commercial license key here after purchase ----';
const videoInstance = await initializeVideoViewer(
instance,
{
license,
},
);
await videoInstance.UI.enableCompareMode();
});</pre>
</dd>
<hr>
<dt>
<h4 class="name" id=".getFrames"><span class="type-signature"><static> </span>getFrames(framesToGet)</h4>
</dt>
<dd>
<div class="description">
Asynchronously retrieves frames from the loaded video in WebViewer Video
</div>
<h5>Parameters:</h5>
<table class="params table table-striped">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>framesToGet</code></td>
<td class="type">
<span class="param-type">Array.<number></span>
</td>
<td class="description last">an array of frame numbers to retrieve</td>
</tr>
</tbody>
</table>
<dl class="details">
</dl>
<h5>Returns:</h5>
<div class="param-desc">
Returns a map of the frames as type HTMLCanvasElement.
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">Object</span>
</dd>
</dl>
<h5>Example</h5>
<pre class="sunlight-highlight-javascript">WebViewer(...)
.then(function(instance) {
const license = '---- Insert commercial license key here after purchase ----';
const videoInstance = await initializeVideoViewer(
instance,
{
license,
},
);
const documentViewer = instance.Core.documentViewer;
documentViewer.addEventListener('videoElementReady', async () => {
const frames = await videoInstance.UI.getFrames([0, 125]);
// YOUR CODE HERE
});
});</pre>
</dd>
<hr>
<dt>
<h4 class="name" id=".loadCompareVideoA"><span class="type-signature"><static> </span>loadCompareVideoA(url, options)</h4>
</dt>
<dd>
<div class="description">
Loads a video for the first video instance in compare mode
</div>
<h5>Parameters:</h5>
<table class="params table table-striped">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>url</code></td>
<td class="type">
<span class="param-type">string</span>
|
<span class="param-type">Blob</span>
|
<span class="param-type">File</span>
</td>
<td class="description last">The video url or video file or video blob</td>
</tr>
<tr>
<td class="name"><code>options</code></td>
<td class="type">
<span class="param-type">Object</span>
</td>
<td class="description last">Optional options object
<h6 class="method-params-label method-subparams-label">Properties</h6>
<table class="params table table-striped">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Argument</th>
<th>Default</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>fileName</code></td>
<td class="type">
<span class="param-type">string</span>
</td>
<td class="attributes">
<optional><br>
</td>
<td class="default">
</td>
<td class="description last">Name of the file. URLs without an extension need this property set</td>
</tr>
<tr>
<td class="name"><code>headers</code></td>
<td class="type">
<span class="param-type">Object</span>
</td>
<td class="attributes">
<optional><br>
</td>
<td class="default">
</td>
<td class="description last">Custom headers to attach when making http requests to provided URL</td>
</tr>
<tr>
<td class="name"><code>withCredentials</code></td>
<td class="type">
<span class="param-type">Object</span>
</td>
<td class="attributes">
<optional><br>
</td>
<td class="default">
false
</td>
<td class="description last">CORS requests for this element will have the credentials flag set to 'include'</td>
</tr>
<tr>
<td class="name"><code>generatedPeaks</code></td>
<td class="type">
<span class="param-type">Array</span>
</td>
<td class="attributes">
<optional><br>
</td>
<td class="default">
null
</td>
<td class="description last">An array of pre-generated peaks for corresponding video file</td>
</tr>
<tr>
<td class="name"><code>useShakaPlayer</code></td>
<td class="type">
<span class="param-type">boolean</span>
</td>
<td class="attributes">
<optional><br>
</td>
<td class="default">
true
</td>
<td class="description last">Runs shaka player integration instead of HTML video</td>
</tr>
<tr>
<td class="name"><code>fps</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="attributes">
<optional><br>
</td>
<td class="default">
null
</td>
<td class="description last">Sets the frames per second of the video. Usually retrieved automatically, but this option may
be used incase that fails.</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
<dl class="details">
</dl>
<h5>Returns:</h5>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">void</span>
</dd>
</dl>
<h5>Example</h5>
<pre class="sunlight-highlight-javascript">WebViewer(...)
.then(function(instance) {
const license = '---- Insert commercial license key here after purchase ----';
const videoInstance = await initializeVideoViewer(
instance,
{
license,
},
);
await videoInstance.UI.enableCompareMode();
videoInstance.UI.loadCompareVideoA(videoUrl);
});</pre>
</dd>
<hr>
<dt>
<h4 class="name" id=".loadCompareVideoB"><span class="type-signature"><static> </span>loadCompareVideoB(url, options)</h4>
</dt>
<dd>
<div class="description">
Loads a video for the second video instance in compare mode
</div>
<h5>Parameters:</h5>
<table class="params table table-striped">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>url</code></td>
<td class="type">
<span class="param-type">string</span>
|
<span class="param-type">Blob</span>
|
<span class="param-type">File</span>
</td>
<td class="description last">The video url or video file or video blob</td>
</tr>
<tr>
<td class="name"><code>options</code></td>
<td class="type">
<span class="param-type">Object</span>
</td>
<td class="description last">Optional options object
<h6 class="method-params-label method-subparams-label">Properties</h6>
<table class="params table table-striped">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Argument</th>
<th>Default</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>fileName</code></td>
<td class="type">
<span class="param-type">string</span>
</td>
<td class="attributes">
<optional><br>
</td>
<td class="default">
</td>
<td class="description last">Name of the file. URLs without an extension need this property set</td>
</tr>
<tr>
<td class="name"><code>headers</code></td>
<td class="type">
<span class="param-type">Object</span>
</td>
<td class="attributes">
<optional><br>
</td>
<td class="default">
</td>
<td class="description last">Custom headers to attach when making http requests to provided URL</td>
</tr>
<tr>
<td class="name"><code>withCredentials</code></td>
<td class="type">
<span class="param-type">Object</span>
</td>
<td class="attributes">
<optional><br>
</td>
<td class="default">
false
</td>
<td class="description last">CORS requests for this element will have the credentials flag set to 'include'</td>
</tr>
<tr>
<td class="name"><code>generatedPeaks</code></td>
<td class="type">
<span class="param-type">Array</span>
</td>
<td class="attributes">
<optional><br>
</td>
<td class="default">
null
</td>
<td class="description last">An array of pre-generated peaks for corresponding video file</td>
</tr>
<tr>
<td class="name"><code>useShakaPlayer</code></td>
<td class="type">
<span class="param-type">boolean</span>
</td>
<td class="attributes">
<optional><br>
</td>
<td class="default">
true
</td>
<td class="description last">Runs shaka player integration instead of HTML video</td>
</tr>
<tr>
<td class="name"><code>fps</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="attributes">
<optional><br>
</td>
<td class="default">
null
</td>
<td class="description last">Sets the frames per second of the video. Usually retrieved automatically, but this option may
be used incase that fails.</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
<dl class="details">
</dl>
<h5>Returns:</h5>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">void</span>
</dd>
</dl>
<h5>Example</h5>
<pre class="sunlight-highlight-javascript">WebViewer(...)
.then(function(instance) {
const license = '---- Insert commercial license key here after purchase ----';
const videoInstance = await initializeVideoViewer(
instance,
{
license,
},
);
await videoInstance.UI.enableCompareMode();
videoInstance.UI.loadCompareVideoA(videoUrl);
window.addEventListener(
'documentViewer2Ready',
() => {
videoInstance.UI.loadCompareVideoB(videoUrl);
},
{ once: true },
);
});</pre>
</dd>
<hr>
<dt>
<h4 class="name" id=".updateElement"><span class="type-signature"><static> </span>updateElement(dataElement, props)</h4>
</dt>
<dd>
<div class="description">
Update an WebViewer Video element in the viewer. Valid options are 'redactApplyButton'.
</div>
<h5>Parameters:</h5>
<table class="params table table-striped">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>dataElement</code></td>
<td class="type">
<span class="param-type">string</span>
</td>
<td class="description last">the data element of the element that will be updated.</td>
</tr>
<tr>
<td class="name"><code>props</code></td>
<td class="type">
<span class="param-type">object</span>
</td>
<td class="description last">an object that is used to override an existing item's properties.</td>
</tr>
</tbody>
</table>
<dl class="details">
</dl>
<h5>Example</h5>
<pre class="sunlight-highlight-javascript">WebViewer(...)
.then(function(instance) {
const license = '---- Insert commercial license key here after purchase ----';
const videoInstance = await initializeVideoViewer(
instance,
{
license,
},
);
videoInstance.UI.updateElement('redactApplyButton', {
onClick: (redactAnnotations) => {
// custom code here
}
});
});</pre>
</dd>
</dl>
</article>
</section>
</div>
</div>
<div class="clearfix"></div>
<div class="col-md-3">
<div id="toc" class="col-md-3 hidden-xs hidden-sm hidden-md"></div>
</div>
</div>
</div>
<div class="modal fade" id="searchResults">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
<h4 class="modal-title">Search results</h4>
</div>
<div class="modal-body"></div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
</div>
<footer>
<span class="jsdoc-message">
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.6.7</a>
on 2025-09-04T11:17:19-07:00
using the <a href="https://github.com/docstrap/docstrap">DocStrap template</a>.
</span>
</footer>
<script src="scripts/docstrap.lib.js"></script>
<script src="scripts/toc.js"></script>
<script type="text/javascript" src="scripts/fulltext-search-ui.js"></script>
<script>
$( function () {
$( "[id*='$']" ).each( function () {
var $this = $( this );
$this.attr( "id", $this.attr( "id" ).replace( "$", "__" ) );
} );
$( ".tutorial-section pre, .readme-section pre, pre.prettyprint.source" ).each( function () {
var $this = $( this );
var example = $this.find( "code" );
exampleText = example.html();
var lang = /{@lang (.*?)}/.exec( exampleText );
if ( lang && lang[1] ) {
exampleText = exampleText.replace( lang[0], "" );
example.html( exampleText );
lang = lang[1];
} else {
var langClassMatch = example.parent()[0].className.match(/lang\-(\S+)/);
lang = langClassMatch ? langClassMatch[1] : "javascript";
}
if ( lang ) {
$this
.addClass( "sunlight-highlight-" + lang )
.addClass( "linenums" )
.html( example.html() );
}
} );
Sunlight.highlightAll( {
lineNumbers : false,
showMenu : true,
enableDoclinks : true
} );
$.catchAnchorLinks( {
navbarOffset: 10
} );
$( "#toc" ).toc( {
anchorName : function ( i, heading, prefix ) {
return $( heading ).attr( "id" ) || ( prefix + i );
},
selectors : "#toc-content h1,#toc-content h2,#toc-content h3,#toc-content h4",
showAndHide : false,
smoothScrolling: true
} );
$( "#main span[id^='toc']" ).addClass( "toc-shim" );
$( '.dropdown-toggle' ).dropdown();
$( "table" ).each( function () {
var $this = $( this );
$this.addClass('table');
} );
} );
</script>
<!--Navigation and Symbol Display-->
<!--Google Analytics-->
<script type="text/javascript">
$(document).ready(function() {
SearcherDisplay.init();
});
</script>
</body>
</html>