Html5
HTML5 Media Controller - Wrapper for HTML5 Media API
DEFINED IN: html5.js line number: 18
EXTENDS: tech.js
Constructor
Html5( [options],[ready] )
Parameters
name | Type | Required | Description |
---|---|---|---|
options | Object | no | Object of option names and values |
ready | function | no | Ready callback function |
Methods
addRemoteTextTrack( options )
Creates a remote text track object and returns a html track element
Parameters
name | Type | Required | Description |
---|---|---|---|
options | Object | yes | The object should contain values for kind, language, label and src (location of the WebVTT file) |
Defined in https://github.com/videojs/video.js/blob/master/src/js/tech/html5.js line number: 736
addTextTrack( kind, [label], [language] )
Creates and returns a text track object
Parameters
name | Type | Required | Description |
---|---|---|---|
kind | String | yes | Text track kind (subtitles, captions, descriptions chapters and metadata) |
label | String | no | Label to identify the text track |
language | String | no | Two letter language abbreviation |
Defined in https://github.com/videojs/video.js/blob/master/src/js/tech/html5.js line number: 718
autoplay()
Get autoplay attribute
Defined in https://github.com/videojs/video.js/blob/master/src/js/tech/html5.js line number: 547
buffered()
Get a TimeRange object that represents the intersection of the time ranges for which the user agent has all relevant media
Defined in https://github.com/videojs/video.js/blob/master/src/js/tech/html5.js line number: 338
controls()
Get controls attribute
Defined in https://github.com/videojs/video.js/blob/master/src/js/tech/html5.js line number: 563
createEl()
Create the component's DOM element
Defined in https://github.com/videojs/video.js/blob/master/src/js/tech/html5.js line number: 121
currentSrc()
Get current source
Defined in https://github.com/videojs/video.js/blob/master/src/js/tech/html5.js line number: 501
currentTime()
Get current time
Defined in https://github.com/videojs/video.js/blob/master/src/js/tech/html5.js line number: 307
defaultMuted()
Get the value of the muted content attribute This attribute has no dynamic effect, it only controls the default state of the element
Defined in https://github.com/videojs/video.js/blob/master/src/js/tech/html5.js line number: 629
dispose()
Dispose of html5 media element
Defined in https://github.com/videojs/video.js/blob/master/src/js/tech/html5.js line number: 93
duration()
Get duration
Defined in https://github.com/videojs/video.js/blob/master/src/js/tech/html5.js line number: 330
ended()
Get if video ended
Defined in https://github.com/videojs/video.js/blob/master/src/js/tech/html5.js line number: 621
enterFullScreen()
Request to enter fullscreen
Defined in https://github.com/videojs/video.js/blob/master/src/js/tech/html5.js line number: 413
error()
Get error value
Defined in https://github.com/videojs/video.js/blob/master/src/js/tech/html5.js line number: 595
exitFullScreen()
Request to exit fullscreen
Defined in https://github.com/videojs/video.js/blob/master/src/js/tech/html5.js line number: 447
height()
Get player height
Defined in https://github.com/videojs/video.js/blob/master/src/js/tech/html5.js line number: 388
load()
Load media into player
Defined in https://github.com/videojs/video.js/blob/master/src/js/tech/html5.js line number: 483
loop()
Get loop attribute
Defined in https://github.com/videojs/video.js/blob/master/src/js/tech/html5.js line number: 579
muted()
Get if muted
Defined in https://github.com/videojs/video.js/blob/master/src/js/tech/html5.js line number: 364
networkState()
Get the current state of network activity for the element, from the list below NETWORK_EMPTY (numeric value 0) NETWORK_IDLE (numeric value 1) NETWORK_LOADING (numeric value 2) NETWORK_NO_SOURCE (numeric value 3)
Defined in https://github.com/videojs/video.js/blob/master/src/js/tech/html5.js line number: 664
pause()
Pause for html5 tech
Defined in https://github.com/videojs/video.js/blob/master/src/js/tech/html5.js line number: 292
paused()
Paused for html5 tech
Defined in https://github.com/videojs/video.js/blob/master/src/js/tech/html5.js line number: 299
play()
Play for html5 tech
Defined in https://github.com/videojs/video.js/blob/master/src/js/tech/html5.js line number: 285
playbackRate()
Get desired speed at which the media resource is to play
Defined in https://github.com/videojs/video.js/blob/master/src/js/tech/html5.js line number: 639
poster()
Get poster
Defined in https://github.com/videojs/video.js/blob/master/src/js/tech/html5.js line number: 515
preload()
Get preload attribute
Defined in https://github.com/videojs/video.js/blob/master/src/js/tech/html5.js line number: 531
readyState()
Get a value that expresses the current state of the element with respect to rendering the current playback position, from the codes in the list below HAVE_NOTHING (numeric value 0) HAVE_METADATA (numeric value 1) HAVE_CURRENT_DATA (numeric value 2) HAVE_FUTURE_DATA (numeric value 3) HAVE_ENOUGH_DATA (numeric value 4)
Defined in https://github.com/videojs/video.js/blob/master/src/js/tech/html5.js line number: 677
removeRemoteTextTrack( track )
Remove remote text track from TextTrackList object
Parameters
name | Type | Required | Description |
---|---|---|---|
track | TextTrackObject | yes | Texttrack object to remove |
Defined in https://github.com/videojs/video.js/blob/master/src/js/tech/html5.js line number: 779
reset()
Reset the tech. Removes all sources and calls load
.
Defined in https://github.com/videojs/video.js/blob/master/src/js/tech/html5.js line number: 492
seekable()
Get a TimeRanges object that represents the ranges of the media resource to which it is possible for the user agent to seek.
Defined in https://github.com/videojs/video.js/blob/master/src/js/tech/html5.js line number: 611
seeking()
Get whether or not the player is in the "seeking" state
Defined in https://github.com/videojs/video.js/blob/master/src/js/tech/html5.js line number: 603
setAutoplay( val )
Set autoplay attribute
Parameters
name | Type | Required | Description |
---|---|---|---|
val | String | yes | Value for preload attribute |
Defined in https://github.com/videojs/video.js/blob/master/src/js/tech/html5.js line number: 555
setControls( val )
Set controls attribute
Parameters
name | Type | Required | Description |
---|---|---|---|
val | String | yes | Value for controls attribute |
Defined in https://github.com/videojs/video.js/blob/master/src/js/tech/html5.js line number: 571
setCurrentTime( seconds )
Set current time
Parameters
name | Type | Required | Description |
---|---|---|---|
seconds | Number | yes | Current time of video |
Defined in https://github.com/videojs/video.js/blob/master/src/js/tech/html5.js line number: 315
setLoop( val )
Set loop attribute
Parameters
name | Type | Required | Description |
---|---|---|---|
val | String | yes | Value for loop attribute |
Defined in https://github.com/videojs/video.js/blob/master/src/js/tech/html5.js line number: 587
setMuted( If )
Set muted
Parameters
name | Type | Required | Description |
---|---|---|---|
If | Boolean | yes | player is to be muted or note |
Defined in https://github.com/videojs/video.js/blob/master/src/js/tech/html5.js line number: 372
setPlaybackRate( val )
Set desired speed at which the media resource is to play
Parameters
name | Type | Required | Description |
---|---|---|---|
val | Number | yes | Speed at which the media resource is to play |
Defined in https://github.com/videojs/video.js/blob/master/src/js/tech/html5.js line number: 656
setPreload( val )
Set preload attribute
Parameters
name | Type | Required | Description |
---|---|---|---|
val | String | yes | Value for preload attribute |
Defined in https://github.com/videojs/video.js/blob/master/src/js/tech/html5.js line number: 539
setSrc( src ) (deprecated)
Set video
Parameters
name | Type | Required | Description |
---|---|---|---|
src | Object | yes | Source object |
Defined in https://github.com/videojs/video.js/blob/master/src/js/tech/html5.js line number: 472
setVolume( percentAsDecimal )
Set volume level
Parameters
name | Type | Required | Description |
---|---|---|---|
percentAsDecimal | Number | yes | Volume percent as a decimal |
Defined in https://github.com/videojs/video.js/blob/master/src/js/tech/html5.js line number: 356
src( [src] )
Get/set video
Parameters
name | Type | Required | Description |
---|---|---|---|
src | Object | no | Source object |
Defined in https://github.com/videojs/video.js/blob/master/src/js/tech/html5.js line number: 456
supportsFullScreen()
Get if there is fullscreen support
Defined in https://github.com/videojs/video.js/blob/master/src/js/tech/html5.js line number: 396
textTracks()
Get text tracks
Defined in https://github.com/videojs/video.js/blob/master/src/js/tech/html5.js line number: 708
videoHeight()
Get height of video
Defined in https://github.com/videojs/video.js/blob/master/src/js/tech/html5.js line number: 700
videoWidth()
Get width of video
Defined in https://github.com/videojs/video.js/blob/master/src/js/tech/html5.js line number: 692
volume()
Get volume level
Defined in https://github.com/videojs/video.js/blob/master/src/js/tech/html5.js line number: 348
width()
Get player width
Defined in https://github.com/videojs/video.js/blob/master/src/js/tech/html5.js line number: 380
bufferedPercent()
Get buffered percent
Defined in https://github.com/videojs/video.js/blob/master/src/js/tech/tech.js line number: 146
emulateTextTracks()
Emulate texttracks
Defined in https://github.com/videojs/video.js/blob/master/src/js/tech/tech.js line number: 316
static getComponent( name )
Gets a component by name
Parameters
name | Type | Required | Description |
---|---|---|---|
name | String | yes | Name of the component to get |
Defined in https://github.com/videojs/video.js/blob/master/src/js/tech/tech.js line number: 509
initTextTrackListeners()
Initialize texttrack listeners
Defined in https://github.com/videojs/video.js/blob/master/src/js/tech/tech.js line number: 293
manualProgressOff()
Turn off progress events
Defined in https://github.com/videojs/video.js/blob/master/src/js/tech/tech.js line number: 91
manualProgressOn()
Turn on progress events
Defined in https://github.com/videojs/video.js/blob/master/src/js/tech/tech.js line number: 77
manualTimeUpdatesOff()
Remove event listeners for on play and pause and tracking current time
Defined in https://github.com/videojs/video.js/blob/master/src/js/tech/tech.js line number: 178
manualTimeUpdatesOn()
Set event listeners for on play and pause and tracking current time
Defined in https://github.com/videojs/video.js/blob/master/src/js/tech/tech.js line number: 166
onDurationChange()
Update duration
Defined in https://github.com/videojs/video.js/blob/master/src/js/tech/tech.js line number: 127
played()
Return the time ranges that have been played through for the current source. This implementation is incomplete. It does not track the played time ranges, only whether the source has played at all or not.
Defined in https://github.com/videojs/video.js/blob/master/src/js/tech/tech.js line number: 267
static registerComponent( name, tech )
Registers a Tech
Parameters
name | Type | Required | Description |
---|---|---|---|
name | String | yes | Name of the Tech to register |
tech | Object | yes | The tech to register |
Defined in https://github.com/videojs/video.js/blob/master/src/js/tech/tech.js line number: 488
remoteTextTrackEls()
Get remote htmltrackelements
Defined in https://github.com/videojs/video.js/blob/master/src/js/tech/tech.js line number: 383
remoteTextTracks()
Get remote texttracks
Defined in https://github.com/videojs/video.js/blob/master/src/js/tech/tech.js line number: 372
setPoster()
Provide a default setPoster method for techs Poster support for techs should be optional, so we don't want techs to break if they don't have a way to set a poster.
Defined in https://github.com/videojs/video.js/blob/master/src/js/tech/tech.js line number: 453
stopTrackingCurrentTime()
Turn off play progress tracking (when paused or dragging)
Defined in https://github.com/videojs/video.js/blob/master/src/js/tech/tech.js line number: 202
stopTrackingProgress()
Stops tracking progress by clearing progress interval
Defined in https://github.com/videojs/video.js/blob/master/src/js/tech/tech.js line number: 156
trackCurrentTime()
Tracks current time
Defined in https://github.com/videojs/video.js/blob/master/src/js/tech/tech.js line number: 190
trackProgress()
Track progress
Defined in https://github.com/videojs/video.js/blob/master/src/js/tech/tech.js line number: 103
$( selector, [context] )
Finds a single DOM element matching selector
within the component's
contentEl
or another custom context.
Parameters
name | Type | Required | Description |
---|---|---|---|
selector | String | yes | A valid CSS selector, which will be passed to querySelector . |
context | Element|String | no | 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 document . |
Defined in https://github.com/videojs/video.js/blob/master/src/js/component.js line number: 841
$$( selector, [context] )
Finds a all DOM elements matching selector
within the component's
contentEl
or another custom context.
Parameters
name | Type | Required | Description |
---|---|---|---|
selector | String | yes | A valid CSS selector, which will be passed to querySelectorAll . |
context | Element|String | no | 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 document . |
Defined in https://github.com/videojs/video.js/blob/master/src/js/component.js line number: 861
addChild( child, [options] )
Adds a child component inside this component
myComponent.el();
// ->
myComponent.children();
// [empty array]
var myButton = myComponent.addChild('MyButton');
// -> Parameters
name Type Required Description child String|Component yes The class name or instance of a child to add options Object no Options, including options to be passed to children of the child.
Defined in https://github.com/videojs/video.js/blob/master/src/js/component.js line number: 315
addClass( classToAdd )
Add a CSS class name to the component's element
Parameters
name Type Required Description classToAdd String yes Classname to add
Defined in https://github.com/videojs/video.js/blob/master/src/js/component.js line number: 892
buildCSSClass()
Allows sub components to stack CSS class names
Defined in https://github.com/videojs/video.js/blob/master/src/js/component.js line number: 593
children()
Get an array of all child components
var kids = myComponent.children();
Defined in https://github.com/videojs/video.js/blob/master/src/js/component.js line number: 282
clearInterval( intervalId )
Clears an interval and removes the associated dispose listener
Parameters
name Type Required Description intervalId Number yes The id of the interval to clear
Defined in https://github.com/videojs/video.js/blob/master/src/js/component.js line number: 1295
clearTimeout( timeoutId )
Clears a timeout and removes the associated dispose listener
Parameters
name Type Required Description timeoutId Number yes The id of the timeout to clear
Defined in https://github.com/videojs/video.js/blob/master/src/js/component.js line number: 1252
contentEl()
Return the component's DOM element where children are inserted.
Will either be the same as el() or a new element defined in createEl().
Defined in https://github.com/videojs/video.js/blob/master/src/js/component.js line number: 245
dimensions( width, height )
Set both width and height at the same time
Parameters
name Type Required Description width Number|String yes Width of player height Number|String yes Height of player
Defined in https://github.com/videojs/video.js/blob/master/src/js/component.js line number: 1015
el()
Get the component's DOM element
var domEl = myComponent.el();
Defined in https://github.com/videojs/video.js/blob/master/src/js/component.js line number: 195
enableTouchActivity()
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.
Defined in https://github.com/videojs/video.js/blob/master/src/js/component.js line number: 1174
static extend( props ) (deprecated)
Sets up the constructor using the supplied init method
or uses the init of the parent object
Parameters
name Type Required Description props Object yes An object of properties
Defined in https://github.com/videojs/video.js/blob/master/src/js/component.js line number: 1350
getChild()
Returns a child component with the provided name
Defined in https://github.com/videojs/video.js/blob/master/src/js/component.js line number: 305
getChildById()
Returns a child component with the provided ID
Defined in https://github.com/videojs/video.js/blob/master/src/js/component.js line number: 295
hasClass( classToCheck )
Check if a component's element has a CSS class name
Parameters
name Type Required Description classToCheck String yes Classname to check
Defined in https://github.com/videojs/video.js/blob/master/src/js/component.js line number: 881
hide()
Hide the component element if currently showing
Defined in https://github.com/videojs/video.js/blob/master/src/js/component.js line number: 944
id()
Get the component's ID
var id = myComponent.id();
Defined in https://github.com/videojs/video.js/blob/master/src/js/component.js line number: 256
initChildren()
Add and initialize default child components from options
// 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
}
});
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.
var myComp = new MyComponent(player, {
children: [
'button',
{
name: 'button',
someOtherOption: true
},
{
name: 'button',
someOtherOption: false
}
]
});
Defined in https://github.com/videojs/video.js/blob/master/src/js/component.js line number: 455
name()
Get the component's name. The name is often used to reference the component.
var name = myComponent.name();
Defined in https://github.com/videojs/video.js/blob/master/src/js/component.js line number: 269
off( first, second, [third] )
Remove an event listener from this component's element
myComponent.off('eventType', myFunc);
If myFunc is excluded, ALL listeners for the event type will be removed.
If eventType is excluded, ALL listeners will be removed from the component.
Alternatively you can use off
to remove listeners that were added to other
elements or components using myComponent.on(otherComponent...
.
In this case both the event type and listener function are REQUIRED.
myComponent.off(otherElement, 'eventType', myFunc);
myComponent.off(otherComponent, 'eventType', myFunc);
Parameters
name Type Required Description first String|Component yes The event type or other component second function|String yes The listener function or event type third function no The listener for other component
Defined in https://github.com/videojs/video.js/blob/master/src/js/component.js line number: 680
on( first, second, third )
Add an event listener to this component's element
var myFunc = function(){
var myComponent = this;
// Do something when the event is fired
};
myComponent.on('eventType', myFunc);
The context of myFunc will be myComponent unless previously bound.
Alternatively, you can add a listener to another element or component.
myComponent.on(otherElement, 'eventName', myFunc);
myComponent.on(otherComponent, 'eventName', myFunc);
The benefit of using this over VjsEvents.on(otherElement, 'eventName', myFunc)
and otherComponent.on('eventName', myFunc)
is that this way the listeners
will be automatically cleaned up when either component is disposed.
It will also bind myComponent as the context of myFunc.
NOTE: When using this on elements in the page other than window
and document (both permanent), if you remove the element from the DOM
you need to call myComponent.trigger(el, 'dispose')
on it to clean up
references to it and allow the browser to garbage collect it.
Parameters
name Type Required Description first String|Component yes The event type or other component second function|String yes The event handler or event type third function yes The event handler
Defined in https://github.com/videojs/video.js/blob/master/src/js/component.js line number: 605
one( first, second, [third] )
Add an event listener to be triggered only once and then removed
myComponent.one('eventName', myFunc);
Alternatively you can add a listener to another element or component
that will be triggered only once.
myComponent.one(otherElement, 'eventName', myFunc);
myComponent.one(otherComponent, 'eventName', myFunc);
Parameters
name Type Required Description first String|Component yes The event type or other component second function|String yes The listener function or event type third function no The listener function for other component
Defined in https://github.com/videojs/video.js/blob/master/src/js/component.js line number: 728
options( obj )
Deep merge of options objects
Whenever a property is an object on both options objects
the two properties will be merged using mergeOptions.
Parent.prototype.options_ = {
optionSet: {
'childOne': { 'foo': 'bar', 'asdf': 'fdsa' },
'childTwo': {},
'childThree': {}
}
}
newOptions = {
optionSet: {
'childOne': { 'foo': 'baz', 'abc': '123' }
'childTwo': null,
'childFour': {}
}
}
this.options(newOptions);
RESULT
{
optionSet: {
'childOne': { 'foo': 'baz', 'asdf': 'fdsa', 'abc': '123' },
'childTwo': null, // Disabled. Won't be initialized.
'childThree': {},
'childFour': {}
}
}
Parameters
name Type Required Description obj Object yes Object of new option values
Defined in https://github.com/videojs/video.js/blob/master/src/js/component.js line number: 145
player()
Return the component's player
Defined in https://github.com/videojs/video.js/blob/master/src/js/component.js line number: 135
ready( fn, sync )
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.
Parameters
name Type Required Description fn function yes Ready listener sync Boolean yes Exec the listener synchronously if component is ready
Defined in https://github.com/videojs/video.js/blob/master/src/js/component.js line number: 787
removeChild( component )
Remove a child component from this component's list of children, and the
child component's element from this component's element
Parameters
name Type Required Description component Component yes Component to remove
Defined in https://github.com/videojs/video.js/blob/master/src/js/component.js line number: 415
removeClass( classToRemove )
Remove a CSS class name from the component's element
Parameters
name Type Required Description classToRemove String yes Classname to remove
Defined in https://github.com/videojs/video.js/blob/master/src/js/component.js line number: 904
setInterval( fn, interval )
Creates an interval and sets up disposal automatically.
Parameters
name Type Required Description fn function yes The function to run every N seconds. interval Number yes Number of ms to delay before executing specified function.
Defined in https://github.com/videojs/video.js/blob/master/src/js/component.js line number: 1271
setTimeout( fn, timeout )
Creates timeout and sets up disposal automatically.
Parameters
name Type Required Description fn function yes The function to run after the timeout. timeout Number yes Number of ms to delay before executing specified function.
Defined in https://github.com/videojs/video.js/blob/master/src/js/component.js line number: 1227
show()
Show the component element if hidden
Defined in https://github.com/videojs/video.js/blob/master/src/js/component.js line number: 933
toggleClass( classToToggle, [predicate] )
Add or remove a CSS class name from the component's element
Parameters
name Type Required Description classToToggle String predicate Boolean|function no Can be a function that returns a Boolean. If true
, the class
will be added; if false
, the class will be removed. If not
given, the class will be added if not present and vice versa.
Defined in https://github.com/videojs/video.js/blob/master/src/js/component.js line number: 916
trigger( event, [hash] )
Trigger an event on an element
myComponent.trigger('eventName');
myComponent.trigger({'type':'eventName'});
myComponent.trigger('eventName', {data: 'some data'});
myComponent.trigger({'type':'eventName'}, {data: 'some data'});
Parameters
name Type Required Description event Event|Object|String yes A string (the type) or an event object with a type attribute hash Object no data hash to pass along with the event
Defined in https://github.com/videojs/video.js/blob/master/src/js/component.js line number: 768
triggerReady()
Trigger the ready listeners
Defined in https://github.com/videojs/video.js/blob/master/src/js/component.js line number: 814