1
0
mirror of https://github.com/videojs/video.js.git synced 2025-01-10 23:30:03 +02:00
video.js/docs/legacy-docs/api/video.html

286 lines
55 KiB
HTML

<!DOCTYPE html><html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"/><title>videojs</title><script src="//use.edgefonts.net/source-code-pro.js">
// font for code blocks
</script><link href="https://fonts.googleapis.com/css?family=Open+Sans:400italic,700italic,400,700" rel="stylesheet" type="text/css"/> <!-- there are many other style for highlighted code here: https://cdnjs.com/libraries/highlight.js --><link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/8.6/styles/atelier-forest.light.min.css"/><link rel="stylesheet" type="text/css" href="css/api-docs.css"/><link rel="canonical" href="https://docs.videojs.com">
</head><body>
<p class="legacydocsnote">This documentation is for an outdated version of Video.js. See <a href="https://docs.videojs.com">documentation for the current release</a>.
<section id="index" class="side-nav"><h2 class="sideNavHeader"><a href="index.html">API Index</a></h2><div id="memberIndex" class="member-index"><h3>videojs Methods</h3><h4>Class Methods</h4><ul id="methodsList"><li><a href="#MethodsaddClass">addClass</a></li><li><a href="#MethodsaddLanguage">addLanguage</a></li><li><a href="#MethodsappendContent">appendContent</a></li><li><a href="#MethodscreateEl">createEl</a></li><li><a href="#MethodscreateTimeRange">createTimeRange</a></li><li><a href="#MethodsemptyEl">emptyEl</a></li><li><a href="#Methodsextend">extend</a></li><li><a href="#MethodsformatTime">formatTime</a></li><li><a href="#MethodsgetAttributes">getAttributes</a></li><li><a href="#MethodsgetComponent">getComponent</a></li><li><a href="#MethodsgetPlayers">getPlayers</a></li><li><a href="#MethodshasClass">hasClass</a></li><li><a href="#MethodsinsertContent">insertContent</a></li><li><a href="#MethodsisCrossOrigin">isCrossOrigin</a></li><li><a href="#MethodsisEl">isEl</a></li><li><a href="#MethodsisTextNode">isTextNode</a></li><li><a href="#MethodsmergeOptions">mergeOptions</a></li><li><a href="#Methodsoff">off</a></li><li><a href="#Methodson">on</a></li><li><a href="#Methodsone">one</a></li><li><a href="#MethodsparseUrl">parseUrl</a></li><li><a href="#Methodsplugin">plugin</a></li><li><a href="#MethodsregisterComponent">registerComponent</a></li><li><a href="#MethodsregisterTech">registerTech</a></li><li><a href="#MethodsremoveClass">removeClass</a></li><li><a href="#MethodssetAttributes">setAttributes</a></li><li><a href="#MethodstoggleElClass">toggleElClass</a></li><li><a href="#Methodstrigger">trigger</a></li><li><a href="#Methodsvideojs">videojs</a></li></ul><h4>Inherited Methods from Component</h4><ul><li><a href="#Methods$">$</a></li><li><a href="#Methods$$">$$</a></li><li><a href="#MethodsaddChild">addChild</a></li><li><a href="#MethodsbuildCSSClass">buildCSSClass</a></li><li><a href="#Methodschildren">children</a></li><li><a href="#MethodsclearInterval">clearInterval</a></li><li><a href="#MethodsclearTimeout">clearTimeout</a></li><li><a href="#MethodscontentEl">contentEl</a></li><li><a href="#Methodsdimensions">dimensions</a></li><li><a href="#Methodsdispose">dispose</a></li><li><a href="#Methodsel">el</a></li><li><a href="#MethodsenableTouchActivity">enableTouchActivity</a></li><li><a href="#MethodsgetChild">getChild</a></li><li><a href="#MethodsgetChildById">getChildById</a></li><li><a href="#Methodsheight">height</a></li><li><a href="#Methodshide">hide</a></li><li><a href="#Methodsid">id</a></li><li><a href="#MethodsinitChildren">initChildren</a></li><li><a href="#Methodsname">name</a></li><li><a href="#Methodsoptions">options</a></li><li><a href="#Methodsplayer">player</a></li><li><a href="#Methodsready">ready</a></li><li><a href="#MethodsremoveChild">removeChild</a></li><li><a href="#MethodssetInterval">setInterval</a></li><li><a href="#MethodssetTimeout">setTimeout</a></li><li><a href="#Methodsshow">show</a></li><li><a href="#MethodstoggleClass">toggleClass</a></li><li><a href="#MethodstriggerReady">triggerReady</a></li><li><a href="#Methodswidth">width</a></li></ul></div></section><div id="main" class="section"><section id="top" class="section"><h1>videojs</h1><div style="border:none" id="classDescription" class="description"><p>Doubles as the main function for users to create a player instance and also
the main library object.
The <code>videojs</code> function can be used to initialize or retrieve a player.</p>
<pre class="prettyprint source lang-js"><code> var myPlayer = videojs('my_video_id');</code></pre></div><p>DEFINED IN: <a href="https://github.com/videojs/video.js/blob/master/src/js/video.js#L40">video.js line number: 40</a></p><p>EXTENDS: <a href="component.html">component.js</a></p></section><section id="methods" class="section"><h2>Methods</h2><div id="MethodsaddClass"><h3 id="addClassHeader">addClass( element, classToAdd )</h3><div id="addClassDescription" class="description"><p>Add a CSS class name to an element</p></div><h4>Parameters</h4><table><thead><tr><th>name</th><th>Type</th><th>Required</th><th>Description</th></tr></thead><tbody><tr><td>element</td><td>Element</td><td>yes</td><td>Element to add class name to</td></tr><tr><td>classToAdd</td><td>String</td><td>yes</td><td>Classname to add</td></tr></tbody></table><p class="vjs-only"><em id="addClassFooter">Defined in <a href="https://github.com/videojs/video.js/blob/master/src/js/video.js#L586">https://github.com/videojs/video.js/blob/master/src/js/video.js line number: 586</a></em></p><p><a href="#top">[back to top]</a></p></div><div id="MethodsaddLanguage"><h3 id="addLanguageHeader">addLanguage( code, data )</h3><div id="addLanguageDescription" class="description"><p>Adding languages so that they're available to all players.</p>
<pre class="prettyprint source lang-js"><code> videojs.addLanguage('es', { 'Hello': 'Hola' });</code></pre></div><h4>Parameters</h4><table><thead><tr><th>name</th><th>Type</th><th>Required</th><th>Description</th></tr></thead><tbody><tr><td>code</td><td>String</td><td>yes</td><td>The language code or dictionary property</td></tr><tr><td>data</td><td>Object</td><td>yes</td><td>The data values to be translated</td></tr></tbody></table><p class="vjs-only"><em id="addLanguageFooter">Defined in <a href="https://github.com/videojs/video.js/blob/master/src/js/video.js#L403">https://github.com/videojs/video.js/blob/master/src/js/video.js line number: 403</a></em></p><p><a href="#top">[back to top]</a></p></div><div id="MethodsappendContent"><h3 id="appendContentHeader">appendContent( el, content )</h3><div id="appendContentDescription" class="description"><p>Normalizes and appends content to an element.</p>
<p>The content for an element can be passed in multiple types and
combinations, whose behavior is as follows:</p>
<ul>
<li><p>String
Normalized into a text node.</p>
</li>
<li><p>Element, TextNode
Passed through.</p>
</li>
<li><p>Array
A one-dimensional array of strings, elements, nodes, or functions (which
return single strings, elements, or nodes).</p>
</li>
<li><p>Function
If the sole argument, is expected to produce a string, element,
node, or array.</p>
</li>
</ul></div><h4>Parameters</h4><table><thead><tr><th>name</th><th>Type</th><th>Required</th><th>Description</th></tr></thead><tbody><tr><td>el</td><td>Element</td></tr><tr><td>content</td><td>String|Element|TextNode|Array|function</td></tr></tbody></table><p class="vjs-only"><em id="appendContentFooter">Defined in <a href="https://github.com/videojs/video.js/blob/master/src/js/video.js#L648">https://github.com/videojs/video.js/blob/master/src/js/video.js line number: 648</a></em></p><p><a href="#top">[back to top]</a></p></div><div id="MethodscreateEl"><h3 id="createElHeader">createEl( [tagName], [properties], [attributes] )</h3><div id="createElDescription" class="description"><p>Creates an element and applies properties.</p></div><h4>Parameters</h4><table><thead><tr><th>name</th><th>Type</th><th>Required</th><th>Description</th></tr></thead><tbody><tr><td>tagName</td><td>String</td><td>no</td><td>Name of tag to be created.</td></tr><tr><td>properties</td><td>Object</td><td>no</td><td>Element properties to be applied.</td></tr><tr><td>attributes</td><td>Object</td><td>no</td><td>Element attributes to be applied.</td></tr></tbody></table><p class="vjs-only"><em id="createElFooter">Defined in <a href="https://github.com/videojs/video.js/blob/master/src/js/video.js#L566">https://github.com/videojs/video.js/blob/master/src/js/video.js line number: 566</a></em></p><p><a href="#top">[back to top]</a></p></div><div id="MethodscreateTimeRange"><h3 id="createTimeRangeHeader">createTimeRange( start, end )</h3><div id="createTimeRangeDescription" class="description"><p>Creates an emulated TimeRange object.</p></div><h4>Parameters</h4><table><thead><tr><th>name</th><th>Type</th><th>Required</th><th>Description</th></tr></thead><tbody><tr><td>start</td><td>Number|Array</td><td>yes</td><td>Start time in seconds or an array of ranges</td></tr><tr><td>end</td><td>Number</td><td>yes</td><td>End time in seconds</td></tr></tbody></table><p class="vjs-only"><em id="createTimeRangeFooter">Defined in <a href="https://github.com/videojs/video.js/blob/master/src/js/video.js#L427">https://github.com/videojs/video.js/blob/master/src/js/video.js line number: 427</a></em></p><p><a href="#top">[back to top]</a></p></div><div id="MethodsemptyEl"><h3 id="emptyElHeader">emptyEl( el )</h3><div id="emptyElDescription" class="description"><p>Empties the contents of an element.</p></div><h4>Parameters</h4><table><thead><tr><th>name</th><th>Type</th><th>Required</th><th>Description</th></tr></thead><tbody><tr><td>el</td><td>Element</td></tr></tbody></table><p class="vjs-only"><em id="emptyElFooter">Defined in <a href="https://github.com/videojs/video.js/blob/master/src/js/video.js#L639">https://github.com/videojs/video.js/blob/master/src/js/video.js line number: 639</a></em></p><p><a href="#top">[back to top]</a></p></div><div id="Methodsextend"><h3 id="extendHeader">extend( The, An )</h3><div id="extendDescription" class="description"><p>Subclass an existing class
Mimics ES6 subclassing with the <code>extend</code> keyword</p>
<pre class="prettyprint source lang-js"><code> // Create a basic javascript 'class'
function MyClass(name){
// Set a property at initialization
this.myName = name;
}
// Create an instance method
MyClass.prototype.sayMyName = function(){
alert(this.myName);
};
// Subclass the exisitng class and change the name
// when initializing
var MySubClass = videojs.extend(MyClass, {
constructor: function(name) {
// Call the super class constructor for the subclass
MyClass.call(this, name)
}
});
// Create an instance of the new sub class
var myInstance = new MySubClass('John');
myInstance.sayMyName(); // -> should alert "John"</code></pre></div><h4>Parameters</h4><table><thead><tr><th>name</th><th>Type</th><th>Required</th><th>Description</th></tr></thead><tbody><tr><td>The</td><td>function</td><td>yes</td><td>Class to subclass</td></tr><tr><td>An</td><td>Object</td><td>yes</td><td>object including instace methods for the new class
Optionally including a <code>constructor</code> function</td></tr></tbody></table><p class="vjs-only"><em id="extendFooter">Defined in <a href="https://github.com/videojs/video.js/blob/master/src/js/video.js#L269">https://github.com/videojs/video.js/blob/master/src/js/video.js line number: 269</a></em></p><p><a href="#top">[back to top]</a></p></div><div id="MethodsformatTime"><h3 id="formatTimeHeader">formatTime( seconds, guide )</h3><div id="formatTimeDescription" class="description"><p>Format seconds as a time string, H:MM:SS or M:SS
Supplying a guide (in seconds) will force a number of leading zeros
to cover the length of the guide</p></div><h4>Parameters</h4><table><thead><tr><th>name</th><th>Type</th><th>Required</th><th>Description</th></tr></thead><tbody><tr><td>seconds</td><td>Number</td><td>yes</td><td>Number of seconds to be turned into a string</td></tr><tr><td>guide</td><td>Number</td><td>yes</td><td>Number (in seconds) to model the string after</td></tr></tbody></table><p class="vjs-only"><em id="formatTimeFooter">Defined in <a href="https://github.com/videojs/video.js/blob/master/src/js/video.js#L437">https://github.com/videojs/video.js/blob/master/src/js/video.js line number: 437</a></em></p><p><a href="#top">[back to top]</a></p></div><div id="MethodsgetAttributes"><h3 id="getAttributesHeader">getAttributes( tag )</h3><div id="getAttributesDescription" class="description"><p>Get an element's attribute values, as defined on the HTML tag
Attributes are not the same as properties. They're defined on the tag
or with setAttribute (which shouldn't be used with HTML)
This will return true or false for boolean attributes.</p></div><h4>Parameters</h4><table><thead><tr><th>name</th><th>Type</th><th>Required</th><th>Description</th></tr></thead><tbody><tr><td>tag</td><td>Element</td><td>yes</td><td>Element from which to get tag attributes</td></tr></tbody></table><p class="vjs-only"><em id="getAttributesFooter">Defined in <a href="https://github.com/videojs/video.js/blob/master/src/js/video.js#L627">https://github.com/videojs/video.js/blob/master/src/js/video.js line number: 627</a></em></p><p><a href="#top">[back to top]</a></p></div><div id="MethodsgetComponent"><h3 id="getComponentHeader">getComponent()</h3><div id="getComponentDescription" class="description"><p>Get a component class object by name</p>
<pre class="prettyprint source lang-js"><code> var VjsButton = videojs.getComponent('Button');
// Create a new instance of the component
var myButton = new VjsButton(myPlayer);</code></pre></div><p class="vjs-only"><em id="getComponentFooter">Defined in <a href="https://github.com/videojs/video.js/blob/master/src/js/video.js#L166">https://github.com/videojs/video.js/blob/master/src/js/video.js line number: 166</a></em></p><p><a href="#top">[back to top]</a></p></div><div id="MethodsgetPlayers"><h3 id="getPlayersHeader">getPlayers()</h3><div id="getPlayersDescription" class="description"><p>Get an object with the currently created players, keyed by player ID</p></div><p class="vjs-only"><em id="getPlayersFooter">Defined in <a href="https://github.com/videojs/video.js/blob/master/src/js/video.js#L143">https://github.com/videojs/video.js/blob/master/src/js/video.js line number: 143</a></em></p><p><a href="#top">[back to top]</a></p></div><div id="MethodshasClass"><h3 id="hasClassHeader">hasClass( element, classToCheck )</h3><div id="hasClassDescription" class="description"><p>Check if an element has a CSS class</p></div><h4>Parameters</h4><table><thead><tr><th>name</th><th>Type</th><th>Required</th><th>Description</th></tr></thead><tbody><tr><td>element</td><td>Element</td><td>yes</td><td>Element to check</td></tr><tr><td>classToCheck</td><td>String</td><td>yes</td><td>Classname to check</td></tr></tbody></table><p class="vjs-only"><em id="hasClassFooter">Defined in <a href="https://github.com/videojs/video.js/blob/master/src/js/video.js#L577">https://github.com/videojs/video.js/blob/master/src/js/video.js line number: 577</a></em></p><p><a href="#top">[back to top]</a></p></div><div id="MethodsinsertContent"><h3 id="insertContentHeader">insertContent( el, content )</h3><div id="insertContentDescription" class="description"><p>Normalizes and inserts content into an element; this is identical to
<code>appendContent()</code>, except it empties the element first.</p>
<p>The content for an element can be passed in multiple types and
combinations, whose behavior is as follows:</p>
<ul>
<li><p>String
Normalized into a text node.</p>
</li>
<li><p>Element, TextNode
Passed through.</p>
</li>
<li><p>Array
A one-dimensional array of strings, elements, nodes, or functions (which
return single strings, elements, or nodes).</p>
</li>
<li><p>Function
If the sole argument, is expected to produce a string, element,
node, or array.</p>
</li>
</ul></div><h4>Parameters</h4><table><thead><tr><th>name</th><th>Type</th><th>Required</th><th>Description</th></tr></thead><tbody><tr><td>el</td><td>Element</td></tr><tr><td>content</td><td>String|Element|TextNode|Array|function</td></tr></tbody></table><p class="vjs-only"><em id="insertContentFooter">Defined in <a href="https://github.com/videojs/video.js/blob/master/src/js/video.js#L675">https://github.com/videojs/video.js/blob/master/src/js/video.js line number: 675</a></em></p><p><a href="#top">[back to top]</a></p></div><div id="MethodsisCrossOrigin"><h3 id="isCrossOriginHeader">isCrossOrigin( url )</h3><div id="isCrossOriginDescription" class="description"><p>Returns whether the url passed is a cross domain request or not.</p></div><h4>Parameters</h4><table><thead><tr><th>name</th><th>Type</th><th>Required</th><th>Description</th></tr></thead><tbody><tr><td>url</td><td>String</td><td>yes</td><td>The url to check</td></tr></tbody></table><p class="vjs-only"><em id="isCrossOriginFooter">Defined in <a href="https://github.com/videojs/video.js/blob/master/src/js/video.js#L458">https://github.com/videojs/video.js/blob/master/src/js/video.js line number: 458</a></em></p><p><a href="#top">[back to top]</a></p></div><div id="MethodsisEl"><h3 id="isElHeader">isEl( value )</h3><div id="isElDescription" class="description"><p>Determines, via duck typing, whether or not a value is a DOM element.</p></div><h4>Parameters</h4><table><thead><tr><th>name</th><th>Type</th><th>Required</th><th>Description</th></tr></thead><tbody><tr><td>value</td><td>Mixed</td></tr></tbody></table><p class="vjs-only"><em id="isElFooter">Defined in <a href="https://github.com/videojs/video.js/blob/master/src/js/video.js#L548">https://github.com/videojs/video.js/blob/master/src/js/video.js line number: 548</a></em></p><p><a href="#top">[back to top]</a></p></div><div id="MethodsisTextNode"><h3 id="isTextNodeHeader">isTextNode( value )</h3><div id="isTextNodeDescription" class="description"><p>Determines, via duck typing, whether or not a value is a text node.</p></div><h4>Parameters</h4><table><thead><tr><th>name</th><th>Type</th><th>Required</th><th>Description</th></tr></thead><tbody><tr><td>value</td><td>Mixed</td></tr></tbody></table><p class="vjs-only"><em id="isTextNodeFooter">Defined in <a href="https://github.com/videojs/video.js/blob/master/src/js/video.js#L557">https://github.com/videojs/video.js/blob/master/src/js/video.js line number: 557</a></em></p><p><a href="#top">[back to top]</a></p></div><div id="MethodsmergeOptions"><h3 id="mergeOptionsHeader">mergeOptions( defaults, overrides, etc )</h3><div id="mergeOptionsDescription" class="description"><p>Merge two options objects recursively
Performs a deep merge like lodash.merge but <strong>only merges plain objects</strong>
(not arrays, elements, anything else)
Other values will be copied directly from the second object.</p>
<pre class="prettyprint source lang-js"><code> var defaultOptions = {
foo: true,
bar: {
a: true,
b: [1,2,3]
}
};
var newOptions = {
foo: false,
bar: {
b: [4,5,6]
}
};
var result = videojs.mergeOptions(defaultOptions, newOptions);
// result.foo = false;
// result.bar.a = true;
// result.bar.b = [4,5,6];</code></pre></div><h4>Parameters</h4><table><thead><tr><th>name</th><th>Type</th><th>Required</th><th>Description</th></tr></thead><tbody><tr><td>defaults</td><td>Object</td><td>yes</td><td>The options object whose values will be overriden</td></tr><tr><td>overrides</td><td>Object</td><td>yes</td><td>The options object with values to override the first</td></tr><tr><td>etc</td><td>Object</td><td>yes</td><td>Any number of additional options objects</td></tr></tbody></table><p class="vjs-only"><em id="mergeOptionsFooter">Defined in <a href="https://github.com/videojs/video.js/blob/master/src/js/video.js#L304">https://github.com/videojs/video.js/blob/master/src/js/video.js line number: 304</a></em></p><p><a href="#top">[back to top]</a></p></div><div id="Methodsoff"><h3 id="offHeader">off( elem, type, fn )</h3><div id="offDescription" class="description"><p>Removes event listeners from an element</p></div><h4>Parameters</h4><table><thead><tr><th>name</th><th>Type</th><th>Required</th><th>Description</th></tr></thead><tbody><tr><td>elem</td><td>Element|Object</td><td>yes</td><td>Object to remove listeners from</td></tr><tr><td>type</td><td>String|Array</td><td>yes</td><td>Type of listener to remove. Don't include to remove all events from element.</td></tr><tr><td>fn</td><td>function</td><td>yes</td><td>Specific listener to remove. Don't include to remove listeners for an event type.</td></tr></tbody></table><p class="vjs-only"><em id="offFooter">Defined in <a href="https://github.com/videojs/video.js/blob/master/src/js/video.js#L497">https://github.com/videojs/video.js/blob/master/src/js/video.js line number: 497</a></em></p><p><a href="#top">[back to top]</a></p></div><div id="Methodson"><h3 id="onHeader">on( elem, type, fn )</h3><div id="onDescription" class="description"><p>Add an event listener to element
It stores the handler function in a separate cache object
and adds a generic handler to the element's event,
along with a unique id (guid) to the element.</p></div><h4>Parameters</h4><table><thead><tr><th>name</th><th>Type</th><th>Required</th><th>Description</th></tr></thead><tbody><tr><td>elem</td><td>Element|Object</td><td>yes</td><td>Element or object to bind listeners to</td></tr><tr><td>type</td><td>String|Array</td><td>yes</td><td>Type of event to bind to.</td></tr><tr><td>fn</td><td>function</td><td>yes</td><td>Event listener.</td></tr></tbody></table><p class="vjs-only"><em id="onFooter">Defined in <a href="https://github.com/videojs/video.js/blob/master/src/js/video.js#L474">https://github.com/videojs/video.js/blob/master/src/js/video.js line number: 474</a></em></p><p><a href="#top">[back to top]</a></p></div><div id="Methodsone"><h3 id="oneHeader">one( elem, type, fn )</h3><div id="oneDescription" class="description"><p>Trigger a listener only once for an event</p></div><h4>Parameters</h4><table><thead><tr><th>name</th><th>Type</th><th>Required</th><th>Description</th></tr></thead><tbody><tr><td>elem</td><td>Element|Object</td><td>yes</td><td>Element or object to</td></tr><tr><td>type</td><td>String|Array</td><td>yes</td><td>Name/type of event</td></tr><tr><td>fn</td><td>function</td><td>yes</td><td>Event handler function</td></tr></tbody></table><p class="vjs-only"><em id="oneFooter">Defined in <a href="https://github.com/videojs/video.js/blob/master/src/js/video.js#L487">https://github.com/videojs/video.js/blob/master/src/js/video.js line number: 487</a></em></p><p><a href="#top">[back to top]</a></p></div><div id="MethodsparseUrl"><h3 id="parseUrlHeader">parseUrl( url )</h3><div id="parseUrlDescription" class="description"><p>Resolve and parse the elements of a URL</p></div><h4>Parameters</h4><table><thead><tr><th>name</th><th>Type</th><th>Required</th><th>Description</th></tr></thead><tbody><tr><td>url</td><td>String</td><td>yes</td><td>The url to parse</td></tr></tbody></table><p class="vjs-only"><em id="parseUrlFooter">Defined in <a href="https://github.com/videojs/video.js/blob/master/src/js/video.js#L449">https://github.com/videojs/video.js/blob/master/src/js/video.js line number: 449</a></em></p><p><a href="#top">[back to top]</a></p></div><div id="Methodsplugin"><h3 id="pluginHeader">plugin( name, fn )</h3><div id="pluginDescription" class="description"><p>Create a Video.js player plugin
Plugins are only initialized when options for the plugin are included
in the player options, or the plugin function on the player instance is
called.
<strong>See the plugin guide in the docs for a more detailed example</strong></p>
<pre class="prettyprint source lang-js"><code> // Make a plugin that alerts when the player plays
videojs.plugin('myPlugin', function(myPluginOptions) {
myPluginOptions = myPluginOptions || {};
var player = this;
var alertText = myPluginOptions.text || 'Player is playing!'
player.on('play', function(){
alert(alertText);
});
});
// USAGE EXAMPLES
// EXAMPLE 1: New player with plugin options, call plugin immediately
var player1 = videojs('idOne', {
myPlugin: {
text: 'Custom text!'
}
});
// Click play
// --> Should alert 'Custom text!'
// EXAMPLE 3: New player, initialize plugin later
var player3 = videojs('idThree');
// Click play
// --> NO ALERT
// Click pause
// Initialize plugin using the plugin function on the player instance
player3.myPlugin({
text: 'Plugin added later!'
});
// Click play
// --> Should alert 'Plugin added later!'</code></pre></div><h4>Parameters</h4><table><thead><tr><th>name</th><th>Type</th><th>Required</th><th>Description</th></tr></thead><tbody><tr><td>name</td><td>String</td><td>yes</td><td>The plugin name</td></tr><tr><td>fn</td><td>function</td><td>yes</td><td>The plugin function that will be called with options</td></tr></tbody></table><p class="vjs-only"><em id="pluginFooter">Defined in <a href="https://github.com/videojs/video.js/blob/master/src/js/video.js#L356">https://github.com/videojs/video.js/blob/master/src/js/video.js line number: 356</a></em></p><p><a href="#top">[back to top]</a></p></div><div id="MethodsregisterComponent"><h3 id="registerComponentHeader">registerComponent( The, The )</h3><div id="registerComponentDescription" class="description"><p>Register a component so it can referred to by name
Used when adding to other
components, either through addChild
<code>component.addChild('myComponent')</code>
or through default children options
<code>{ children: ['myComponent'] }</code>.</p>
<pre class="prettyprint source lang-js"><code> // Get a component to subclass
var VjsButton = videojs.getComponent('Button');
// Subclass the component (see 'extend' doc for more info)
var MySpecialButton = videojs.extend(VjsButton, {});
// Register the new component
VjsButton.registerComponent('MySepcialButton', MySepcialButton);
// (optionally) add the new component as a default player child
myPlayer.addChild('MySepcialButton');</code></pre><p>NOTE: You could also just initialize the component before adding.
<code>component.addChild(new MyComponent());</code></p></div><h4>Parameters</h4><table><thead><tr><th>name</th><th>Type</th><th>Required</th><th>Description</th></tr></thead><tbody><tr><td>The</td><td>String</td><td>yes</td><td>class name of the component</td></tr><tr><td>The</td><td>Component</td><td>yes</td><td>component class</td></tr></tbody></table><p class="vjs-only"><em id="registerComponentFooter">Defined in <a href="https://github.com/videojs/video.js/blob/master/src/js/video.js#L180">https://github.com/videojs/video.js/blob/master/src/js/video.js line number: 180</a></em></p><p><a href="#top">[back to top]</a></p></div><div id="MethodsregisterTech"><h3 id="registerTechHeader">registerTech( The, The )</h3><div id="registerTechDescription" class="description"><p>Register a Tech so it can referred to by name.
This is used in the tech order for the player.</p>
<pre class="prettyprint source lang-js"><code> // get the Html5 Tech
var Html5 = videojs.getTech('Html5');
var MyTech = videojs.extend(Html5, {});
// Register the new Tech
VjsButton.registerTech('Tech', MyTech);
var player = videojs('myplayer', {
techOrder: ['myTech', 'html5']
});</code></pre></div><h4>Parameters</h4><table><thead><tr><th>name</th><th>Type</th><th>Required</th><th>Description</th></tr></thead><tbody><tr><td>The</td><td>String</td><td>yes</td><td>class name of the tech</td></tr><tr><td>The</td><td>Tech</td><td>yes</td><td>tech class</td></tr></tbody></table><p class="vjs-only"><em id="registerTechFooter">Defined in <a href="https://github.com/videojs/video.js/blob/master/src/js/video.js#L228">https://github.com/videojs/video.js/blob/master/src/js/video.js line number: 228</a></em></p><p><a href="#top">[back to top]</a></p></div><div id="MethodsremoveClass"><h3 id="removeClassHeader">removeClass( element, classToRemove )</h3><div id="removeClassDescription" class="description"><p>Remove a CSS class name from an element</p></div><h4>Parameters</h4><table><thead><tr><th>name</th><th>Type</th><th>Required</th><th>Description</th></tr></thead><tbody><tr><td>element</td><td>Element</td><td>yes</td><td>Element to remove from class name</td></tr><tr><td>classToRemove</td><td>String</td><td>yes</td><td>Classname to remove</td></tr></tbody></table><p class="vjs-only"><em id="removeClassFooter">Defined in <a href="https://github.com/videojs/video.js/blob/master/src/js/video.js#L595">https://github.com/videojs/video.js/blob/master/src/js/video.js line number: 595</a></em></p><p><a href="#top">[back to top]</a></p></div><div id="MethodssetAttributes"><h3 id="setAttributesHeader">setAttributes( el, [attributes] )</h3><div id="setAttributesDescription" class="description"><p>Apply attributes to an HTML element.</p></div><h4>Parameters</h4><table><thead><tr><th>name</th><th>Type</th><th>Required</th><th>Description</th></tr></thead><tbody><tr><td>el</td><td>Element</td><td>yes</td><td>Target element.</td></tr><tr><td>attributes</td><td>Object</td><td>no</td><td>Element attributes to be applied.</td></tr></tbody></table><p class="vjs-only"><em id="setAttributesFooter">Defined in <a href="https://github.com/videojs/video.js/blob/master/src/js/video.js#L618">https://github.com/videojs/video.js/blob/master/src/js/video.js line number: 618</a></em></p><p><a href="#top">[back to top]</a></p></div><div id="MethodstoggleElClass"><h3 id="toggleElClassHeader">toggleElClass( element, classToToggle, [predicate] )</h3><div id="toggleElClassDescription" class="description"><p>Adds or removes a CSS class name on an element depending on an optional
condition or the presence/absence of the class name.</p></div><h4>Parameters</h4><table><thead><tr><th>name</th><th>Type</th><th>Required</th><th>Description</th></tr></thead><tbody><tr><td>element</td><td>Element</td></tr><tr><td>classToToggle</td><td>String</td></tr><tr><td>predicate</td><td>Boolean|function</td><td>no</td><td>Can be a function that returns a Boolean. If <code>true</code>, the class
will be added; if <code>false</code>, the class will be removed. If not
given, the class will be added if not present and vice versa.</td></tr></tbody></table><p class="vjs-only"><em id="toggleElClassFooter">Defined in <a href="https://github.com/videojs/video.js/blob/master/src/js/video.js#L604">https://github.com/videojs/video.js/blob/master/src/js/video.js line number: 604</a></em></p><p><a href="#top">[back to top]</a></p></div><div id="Methodstrigger"><h3 id="triggerHeader">trigger( elem, event, [hash] )</h3><div id="triggerDescription" class="description"><p>Trigger an event for an element</p></div><h4>Parameters</h4><table><thead><tr><th>name</th><th>Type</th><th>Required</th><th>Description</th></tr></thead><tbody><tr><td>elem</td><td>Element|Object</td><td>yes</td><td>Element to trigger an event on</td></tr><tr><td>event</td><td>Event|Object|String</td><td>yes</td><td>A string (the type) or an event object with a type attribute</td></tr><tr><td>hash</td><td>Object</td><td>no</td><td>data hash to pass along with the event</td></tr></tbody></table><p class="vjs-only"><em id="triggerFooter">Defined in <a href="https://github.com/videojs/video.js/blob/master/src/js/video.js#L507">https://github.com/videojs/video.js/blob/master/src/js/video.js line number: 507</a></em></p><p><a href="#top">[back to top]</a></p></div><div id="Methodsvideojs"><h3 id="videojsHeader">videojs( id, [options], [ready] )</h3><div id="videojsDescription" class="description"><p>Doubles as the main function for users to create a player instance and also
the main library object.
The <code>videojs</code> function can be used to initialize or retrieve a player.</p>
<pre class="prettyprint source lang-js"><code> var myPlayer = videojs('my_video_id');</code></pre></div><h4>Parameters</h4><table><thead><tr><th>name</th><th>Type</th><th>Required</th><th>Description</th></tr></thead><tbody><tr><td>id</td><td>String|Element</td><td>yes</td><td>Video element or video element ID</td></tr><tr><td>options</td><td>Object</td><td>no</td><td>Optional options object for config/settings</td></tr><tr><td>ready</td><td>function</td><td>no</td><td>Optional ready callback</td></tr></tbody></table><p class="vjs-only"><em id="videojsFooter">Defined in <a href="https://github.com/videojs/video.js/blob/master/src/js/video.js#L40">https://github.com/videojs/video.js/blob/master/src/js/video.js line number: 40</a></em></p><p><a href="#top">[back to top]</a></p></div><div id="Methods$"><h3 id="$Header">$( selector, [context] )</h3><div id="$Description" class="description"><p>Finds a single DOM element matching <code>selector</code> within the component's
<code>contentEl</code> or another custom context.</p></div><h4>Parameters</h4><table><thead><tr><th>name</th><th>Type</th><th>Required</th><th>Description</th></tr></thead><tbody><tr><td>selector</td><td>String</td><td>yes</td><td>A valid CSS selector, which will be passed to <code>querySelector</code>.</td></tr><tr><td>context</td><td>Element|String</td><td>no</td><td>A DOM element within which to query. Can also be a selector
string in which case the first matching element will be used
as context. If missing (or no element matches selector), falls
back to <code>document</code>.</td></tr></tbody></table><p class="vjs-only"><em id="$Footer">Defined in <a href="https://github.com/videojs/video.js/blob/master/src/js/component.js#L841">https://github.com/videojs/video.js/blob/master/src/js/component.js line number: 841</a></em></p><p><a href="#top">[back to top]</a></p></div><div id="Methods$$"><h3 id="$$Header">$$( selector, [context] )</h3><div id="$$Description" class="description"><p>Finds a all DOM elements matching <code>selector</code> within the component's
<code>contentEl</code> or another custom context.</p></div><h4>Parameters</h4><table><thead><tr><th>name</th><th>Type</th><th>Required</th><th>Description</th></tr></thead><tbody><tr><td>selector</td><td>String</td><td>yes</td><td>A valid CSS selector, which will be passed to <code>querySelectorAll</code>.</td></tr><tr><td>context</td><td>Element|String</td><td>no</td><td>A DOM element within which to query. Can also be a selector
string in which case the first matching element will be used
as context. If missing (or no element matches selector), falls
back to <code>document</code>.</td></tr></tbody></table><p class="vjs-only"><em id="$$Footer">Defined in <a href="https://github.com/videojs/video.js/blob/master/src/js/component.js#L861">https://github.com/videojs/video.js/blob/master/src/js/component.js line number: 861</a></em></p><p><a href="#top">[back to top]</a></p></div><div id="MethodsaddChild"><h3 id="addChildHeader">addChild( child, [options] )</h3><div id="addChildDescription" class="description"><p>Adds a child component inside this component</p>
<pre class="prettyprint source lang-js"><code> myComponent.el();
// -> <div class='my-component'></div>
myComponent.children();
// [empty array]
var myButton = myComponent.addChild('MyButton');
// -> <div class='my-component'><div class="my-button">myButton<div></div>
// -> myButton === myComponent.children()[0];</code></pre><p>Pass in options for child constructors and options for children of the child</p>
<pre class="prettyprint source lang-js"><code> var myButton = myComponent.addChild('MyButton', {
text: 'Press Me',
buttonChildExample: {
buttonChildOption: true
}
});</code></pre></div><h4>Parameters</h4><table><thead><tr><th>name</th><th>Type</th><th>Required</th><th>Description</th></tr></thead><tbody><tr><td>child</td><td>String|Component</td><td>yes</td><td>The class name or instance of a child to add</td></tr><tr><td>options</td><td>Object</td><td>no</td><td>Options, including options to be passed to children of the child.</td></tr></tbody></table><p class="vjs-only"><em id="addChildFooter">Defined in <a href="https://github.com/videojs/video.js/blob/master/src/js/component.js#L315">https://github.com/videojs/video.js/blob/master/src/js/component.js line number: 315</a></em></p><p><a href="#top">[back to top]</a></p></div><div id="MethodsbuildCSSClass"><h3 id="buildCSSClassHeader">buildCSSClass()</h3><div id="buildCSSClassDescription" class="description"><p>Allows sub components to stack CSS class names</p></div><p class="vjs-only"><em id="buildCSSClassFooter">Defined in <a href="https://github.com/videojs/video.js/blob/master/src/js/component.js#L593">https://github.com/videojs/video.js/blob/master/src/js/component.js line number: 593</a></em></p><p><a href="#top">[back to top]</a></p></div><div id="Methodschildren"><h3 id="childrenHeader">children()</h3><div id="childrenDescription" class="description"><p>Get an array of all child components</p>
<pre class="prettyprint source lang-js"><code> var kids = myComponent.children();</code></pre></div><p class="vjs-only"><em id="childrenFooter">Defined in <a href="https://github.com/videojs/video.js/blob/master/src/js/component.js#L282">https://github.com/videojs/video.js/blob/master/src/js/component.js line number: 282</a></em></p><p><a href="#top">[back to top]</a></p></div><div id="MethodsclearInterval"><h3 id="clearIntervalHeader">clearInterval( intervalId )</h3><div id="clearIntervalDescription" class="description"><p>Clears an interval and removes the associated dispose listener</p></div><h4>Parameters</h4><table><thead><tr><th>name</th><th>Type</th><th>Required</th><th>Description</th></tr></thead><tbody><tr><td>intervalId</td><td>Number</td><td>yes</td><td>The id of the interval to clear</td></tr></tbody></table><p class="vjs-only"><em id="clearIntervalFooter">Defined in <a href="https://github.com/videojs/video.js/blob/master/src/js/component.js#L1295">https://github.com/videojs/video.js/blob/master/src/js/component.js line number: 1295</a></em></p><p><a href="#top">[back to top]</a></p></div><div id="MethodsclearTimeout"><h3 id="clearTimeoutHeader">clearTimeout( timeoutId )</h3><div id="clearTimeoutDescription" class="description"><p>Clears a timeout and removes the associated dispose listener</p></div><h4>Parameters</h4><table><thead><tr><th>name</th><th>Type</th><th>Required</th><th>Description</th></tr></thead><tbody><tr><td>timeoutId</td><td>Number</td><td>yes</td><td>The id of the timeout to clear</td></tr></tbody></table><p class="vjs-only"><em id="clearTimeoutFooter">Defined in <a href="https://github.com/videojs/video.js/blob/master/src/js/component.js#L1252">https://github.com/videojs/video.js/blob/master/src/js/component.js line number: 1252</a></em></p><p><a href="#top">[back to top]</a></p></div><div id="MethodscontentEl"><h3 id="contentElHeader">contentEl()</h3><div id="contentElDescription" class="description"><p>Return the component's DOM element where children are inserted.
Will either be the same as el() or a new element defined in createEl().</p></div><p class="vjs-only"><em id="contentElFooter">Defined in <a href="https://github.com/videojs/video.js/blob/master/src/js/component.js#L245">https://github.com/videojs/video.js/blob/master/src/js/component.js line number: 245</a></em></p><p><a href="#top">[back to top]</a></p></div><div id="Methodsdimensions"><h3 id="dimensionsHeader">dimensions( width, height )</h3><div id="dimensionsDescription" class="description"><p>Set both width and height at the same time</p></div><h4>Parameters</h4><table><thead><tr><th>name</th><th>Type</th><th>Required</th><th>Description</th></tr></thead><tbody><tr><td>width</td><td>Number|String</td><td>yes</td><td>Width of player</td></tr><tr><td>height</td><td>Number|String</td><td>yes</td><td>Height of player</td></tr></tbody></table><p class="vjs-only"><em id="dimensionsFooter">Defined in <a href="https://github.com/videojs/video.js/blob/master/src/js/component.js#L1015">https://github.com/videojs/video.js/blob/master/src/js/component.js line number: 1015</a></em></p><p><a href="#top">[back to top]</a></p></div><div id="Methodsdispose"><h3 id="disposeHeader">dispose()</h3><div id="disposeDescription" class="description"><p>Dispose of the component and all child components</p></div><p class="vjs-only"><em id="disposeFooter">Defined in <a href="https://github.com/videojs/video.js/blob/master/src/js/component.js#L101">https://github.com/videojs/video.js/blob/master/src/js/component.js line number: 101</a></em></p><p><a href="#top">[back to top]</a></p></div><div id="Methodsel"><h3 id="elHeader">el()</h3><div id="elDescription" class="description"><p>Get the component's DOM element</p>
<pre class="prettyprint source lang-js"><code> var domEl = myComponent.el();</code></pre></div><p class="vjs-only"><em id="elFooter">Defined in <a href="https://github.com/videojs/video.js/blob/master/src/js/component.js#L195">https://github.com/videojs/video.js/blob/master/src/js/component.js line number: 195</a></em></p><p><a href="#top">[back to top]</a></p></div><div id="MethodsenableTouchActivity"><h3 id="enableTouchActivityHeader">enableTouchActivity()</h3><div id="enableTouchActivityDescription" class="description"><p>Report user touch activity when touch events occur
User activity is used to determine when controls should show/hide. It's
relatively simple when it comes to mouse events, because any mouse event
should show the controls. So we capture mouse events that bubble up to the
player and report activity when that happens.
With touch events it isn't as easy. We can't rely on touch events at the
player level, because a tap (touchstart + touchend) on the video itself on
mobile devices is meant to turn controls off (and on). User activity is
checked asynchronously, so what could happen is a tap event on the video
turns the controls off, then the touchend event bubbles up to the player,
which if it reported user activity, would turn the controls right back on.
(We also don't want to completely block touch events from bubbling up)
Also a touchmove, touch+hold, and anything other than a tap is not supposed
to turn the controls back on on a mobile device.
Here we're setting the default component behavior to report user activity
whenever touch events happen, and this can be turned off by components that
want touch events to act differently.</p></div><p class="vjs-only"><em id="enableTouchActivityFooter">Defined in <a href="https://github.com/videojs/video.js/blob/master/src/js/component.js#L1174">https://github.com/videojs/video.js/blob/master/src/js/component.js line number: 1174</a></em></p><p><a href="#top">[back to top]</a></p></div><div id="MethodsgetChild"><h3 id="getChildHeader">getChild()</h3><div id="getChildDescription" class="description"><p>Returns a child component with the provided name</p></div><p class="vjs-only"><em id="getChildFooter">Defined in <a href="https://github.com/videojs/video.js/blob/master/src/js/component.js#L305">https://github.com/videojs/video.js/blob/master/src/js/component.js line number: 305</a></em></p><p><a href="#top">[back to top]</a></p></div><div id="MethodsgetChildById"><h3 id="getChildByIdHeader">getChildById()</h3><div id="getChildByIdDescription" class="description"><p>Returns a child component with the provided ID</p></div><p class="vjs-only"><em id="getChildByIdFooter">Defined in <a href="https://github.com/videojs/video.js/blob/master/src/js/component.js#L295">https://github.com/videojs/video.js/blob/master/src/js/component.js line number: 295</a></em></p><p><a href="#top">[back to top]</a></p></div><div id="Methodsheight"><h3 id="heightHeader">height( num, [skipListeners] )</h3><div id="heightDescription" class="description"><p>Get or set the height of the component (CSS values)
Setting the video tag dimension values only works with values in pixels.
Percent values will not work.
Some percents can be used, but width()/height() will return the number + %,
not the actual computed width/height.</p></div><h4>Parameters</h4><table><thead><tr><th>name</th><th>Type</th><th>Required</th><th>Description</th></tr></thead><tbody><tr><td>num</td><td>Number|String</td><td>yes</td><td>New component height</td></tr><tr><td>skipListeners</td><td>Boolean</td><td>no</td><td>Skip the resize event trigger</td></tr></tbody></table><p class="vjs-only"><em id="heightFooter">Defined in <a href="https://github.com/videojs/video.js/blob/master/src/js/component.js#L998">https://github.com/videojs/video.js/blob/master/src/js/component.js line number: 998</a></em></p><p><a href="#top">[back to top]</a></p></div><div id="Methodshide"><h3 id="hideHeader">hide()</h3><div id="hideDescription" class="description"><p>Hide the component element if currently showing</p></div><p class="vjs-only"><em id="hideFooter">Defined in <a href="https://github.com/videojs/video.js/blob/master/src/js/component.js#L944">https://github.com/videojs/video.js/blob/master/src/js/component.js line number: 944</a></em></p><p><a href="#top">[back to top]</a></p></div><div id="Methodsid"><h3 id="idHeader">id()</h3><div id="idDescription" class="description"><p>Get the component's ID</p>
<pre class="prettyprint source lang-js"><code> var id = myComponent.id();</code></pre></div><p class="vjs-only"><em id="idFooter">Defined in <a href="https://github.com/videojs/video.js/blob/master/src/js/component.js#L256">https://github.com/videojs/video.js/blob/master/src/js/component.js line number: 256</a></em></p><p><a href="#top">[back to top]</a></p></div><div id="MethodsinitChildren"><h3 id="initChildrenHeader">initChildren()</h3><div id="initChildrenDescription" class="description"><p>Add and initialize default child components from options</p>
<pre class="prettyprint source lang-js"><code> // when an instance of MyComponent is created, all children in options
// will be added to the instance by their name strings and options
MyComponent.prototype.options_ = {
children: [
'myChildComponent'
],
myChildComponent: {
myChildOption: true
}
};
// Or when creating the component
var myComp = new MyComponent(player, {
children: [
'myChildComponent'
],
myChildComponent: {
myChildOption: true
}
});</code></pre><p>The children option can also be an array of
child options objects (that also include a 'name' key).
This can be used if you have two child components of the
same type that need different options.</p>
<pre class="prettyprint source lang-js"><code> var myComp = new MyComponent(player, {
children: [
'button',
{
name: 'button',
someOtherOption: true
},
{
name: 'button',
someOtherOption: false
}
]
});</code></pre></div><p class="vjs-only"><em id="initChildrenFooter">Defined in <a href="https://github.com/videojs/video.js/blob/master/src/js/component.js#L455">https://github.com/videojs/video.js/blob/master/src/js/component.js line number: 455</a></em></p><p><a href="#top">[back to top]</a></p></div><div id="Methodsname"><h3 id="nameHeader">name()</h3><div id="nameDescription" class="description"><p>Get the component's name. The name is often used to reference the component.</p>
<pre class="prettyprint source lang-js"><code> var name = myComponent.name();</code></pre></div><p class="vjs-only"><em id="nameFooter">Defined in <a href="https://github.com/videojs/video.js/blob/master/src/js/component.js#L269">https://github.com/videojs/video.js/blob/master/src/js/component.js line number: 269</a></em></p><p><a href="#top">[back to top]</a></p></div><div id="Methodsoptions"><h3 id="optionsHeader">options( obj )</h3><div id="optionsDescription" class="description"><p>Deep merge of options objects
Whenever a property is an object on both options objects
the two properties will be merged using mergeOptions.</p>
<pre class="prettyprint source lang-js"><code> Parent.prototype.options_ = {
optionSet: {
'childOne': { 'foo': 'bar', 'asdf': 'fdsa' },
'childTwo': {},
'childThree': {}
}
}
newOptions = {
optionSet: {
'childOne': { 'foo': 'baz', 'abc': '123' }
'childTwo': null,
'childFour': {}
}
}
this.options(newOptions);</code></pre><p>RESULT</p>
<pre class="prettyprint source lang-js"><code> {
optionSet: {
'childOne': { 'foo': 'baz', 'asdf': 'fdsa', 'abc': '123' },
'childTwo': null, // Disabled. Won't be initialized.
'childThree': {},
'childFour': {}
}
}</code></pre></div><h4>Parameters</h4><table><thead><tr><th>name</th><th>Type</th><th>Required</th><th>Description</th></tr></thead><tbody><tr><td>obj</td><td>Object</td><td>yes</td><td>Object of new option values</td></tr></tbody></table><p class="vjs-only"><em id="optionsFooter">Defined in <a href="https://github.com/videojs/video.js/blob/master/src/js/component.js#L145">https://github.com/videojs/video.js/blob/master/src/js/component.js line number: 145</a></em></p><p><a href="#top">[back to top]</a></p></div><div id="Methodsplayer"><h3 id="playerHeader">player()</h3><div id="playerDescription" class="description"><p>Return the component's player</p></div><p class="vjs-only"><em id="playerFooter">Defined in <a href="https://github.com/videojs/video.js/blob/master/src/js/component.js#L135">https://github.com/videojs/video.js/blob/master/src/js/component.js line number: 135</a></em></p><p><a href="#top">[back to top]</a></p></div><div id="Methodsready"><h3 id="readyHeader">ready( fn, sync )</h3><div id="readyDescription" class="description"><p>Bind a listener to the component's ready state.
Different from event listeners in that if the ready event has already happened
it will trigger the function immediately.</p></div><h4>Parameters</h4><table><thead><tr><th>name</th><th>Type</th><th>Required</th><th>Description</th></tr></thead><tbody><tr><td>fn</td><td>function</td><td>yes</td><td>Ready listener</td></tr><tr><td>sync</td><td>Boolean</td><td>yes</td><td>Exec the listener synchronously if component is ready</td></tr></tbody></table><p class="vjs-only"><em id="readyFooter">Defined in <a href="https://github.com/videojs/video.js/blob/master/src/js/component.js#L787">https://github.com/videojs/video.js/blob/master/src/js/component.js line number: 787</a></em></p><p><a href="#top">[back to top]</a></p></div><div id="MethodsremoveChild"><h3 id="removeChildHeader">removeChild( component )</h3><div id="removeChildDescription" class="description"><p>Remove a child component from this component's list of children, and the
child component's element from this component's element</p></div><h4>Parameters</h4><table><thead><tr><th>name</th><th>Type</th><th>Required</th><th>Description</th></tr></thead><tbody><tr><td>component</td><td>Component</td><td>yes</td><td>Component to remove</td></tr></tbody></table><p class="vjs-only"><em id="removeChildFooter">Defined in <a href="https://github.com/videojs/video.js/blob/master/src/js/component.js#L415">https://github.com/videojs/video.js/blob/master/src/js/component.js line number: 415</a></em></p><p><a href="#top">[back to top]</a></p></div><div id="MethodssetInterval"><h3 id="setIntervalHeader">setInterval( fn, interval )</h3><div id="setIntervalDescription" class="description"><p>Creates an interval and sets up disposal automatically.</p></div><h4>Parameters</h4><table><thead><tr><th>name</th><th>Type</th><th>Required</th><th>Description</th></tr></thead><tbody><tr><td>fn</td><td>function</td><td>yes</td><td>The function to run every N seconds.</td></tr><tr><td>interval</td><td>Number</td><td>yes</td><td>Number of ms to delay before executing specified function.</td></tr></tbody></table><p class="vjs-only"><em id="setIntervalFooter">Defined in <a href="https://github.com/videojs/video.js/blob/master/src/js/component.js#L1271">https://github.com/videojs/video.js/blob/master/src/js/component.js line number: 1271</a></em></p><p><a href="#top">[back to top]</a></p></div><div id="MethodssetTimeout"><h3 id="setTimeoutHeader">setTimeout( fn, timeout )</h3><div id="setTimeoutDescription" class="description"><p>Creates timeout and sets up disposal automatically.</p></div><h4>Parameters</h4><table><thead><tr><th>name</th><th>Type</th><th>Required</th><th>Description</th></tr></thead><tbody><tr><td>fn</td><td>function</td><td>yes</td><td>The function to run after the timeout.</td></tr><tr><td>timeout</td><td>Number</td><td>yes</td><td>Number of ms to delay before executing specified function.</td></tr></tbody></table><p class="vjs-only"><em id="setTimeoutFooter">Defined in <a href="https://github.com/videojs/video.js/blob/master/src/js/component.js#L1227">https://github.com/videojs/video.js/blob/master/src/js/component.js line number: 1227</a></em></p><p><a href="#top">[back to top]</a></p></div><div id="Methodsshow"><h3 id="showHeader">show()</h3><div id="showDescription" class="description"><p>Show the component element if hidden</p></div><p class="vjs-only"><em id="showFooter">Defined in <a href="https://github.com/videojs/video.js/blob/master/src/js/component.js#L933">https://github.com/videojs/video.js/blob/master/src/js/component.js line number: 933</a></em></p><p><a href="#top">[back to top]</a></p></div><div id="MethodstoggleClass"><h3 id="toggleClassHeader">toggleClass( classToToggle, [predicate] )</h3><div id="toggleClassDescription" class="description"><p>Add or remove a CSS class name from the component's element</p></div><h4>Parameters</h4><table><thead><tr><th>name</th><th>Type</th><th>Required</th><th>Description</th></tr></thead><tbody><tr><td>classToToggle</td><td>String</td></tr><tr><td>predicate</td><td>Boolean|function</td><td>no</td><td>Can be a function that returns a Boolean. If <code>true</code>, the class
will be added; if <code>false</code>, the class will be removed. If not
given, the class will be added if not present and vice versa.</td></tr></tbody></table><p class="vjs-only"><em id="toggleClassFooter">Defined in <a href="https://github.com/videojs/video.js/blob/master/src/js/component.js#L916">https://github.com/videojs/video.js/blob/master/src/js/component.js line number: 916</a></em></p><p><a href="#top">[back to top]</a></p></div><div id="MethodstriggerReady"><h3 id="triggerReadyHeader">triggerReady()</h3><div id="triggerReadyDescription" class="description"><p>Trigger the ready listeners</p></div><p class="vjs-only"><em id="triggerReadyFooter">Defined in <a href="https://github.com/videojs/video.js/blob/master/src/js/component.js#L814">https://github.com/videojs/video.js/blob/master/src/js/component.js line number: 814</a></em></p><p><a href="#top">[back to top]</a></p></div><div id="Methodswidth"><h3 id="widthHeader">width( num, skipListeners )</h3><div id="widthDescription" class="description"><p>Set or get the width of the component (CSS values)
Setting the video tag dimension values only works with values in pixels.
Percent values will not work.
Some percents can be used, but width()/height() will return the number + %,
not the actual computed width/height.</p></div><h4>Parameters</h4><table><thead><tr><th>name</th><th>Type</th><th>Required</th><th>Description</th></tr></thead><tbody><tr><td>num</td><td>Number|String</td><td>yes</td><td>Optional width number</td></tr><tr><td>skipListeners</td><td>Boolean</td><td>yes</td><td>Skip the 'resize' event trigger</td></tr></tbody></table><p class="vjs-only"><em id="widthFooter">Defined in <a href="https://github.com/videojs/video.js/blob/master/src/js/component.js#L981">https://github.com/videojs/video.js/blob/master/src/js/component.js line number: 981</a></em></p><p><a href="#top">[back to top]</a></p></div></section></div><script src="//cdnjs.cloudflare.com/ajax/libs/highlight.js/8.6/highlight.min.js">
// syntax highlighter for code samples
</script><script src="./js/highlight-syntax.js">
// activates syntax highlighting
</script></body></html>