videojs文档翻译-Player(v6.0.0-RC.2)

Player

当使用任何Video.js设置方法初始化视频时,将创建Player类的实例。

创建实例后,可以通过两种方式在全局访问:

调用videojs('example_video_1');
直接通过videojs.players.example_video_1使用它;

构造函数

new Player(tag, optionsopt, readyopt)

创建此类的实例

参数:
名称类型属性描述
tag Element  

用于配置选项的原始 video DOM 元素。

options Object <optional>

选项名称和值的对象。

ready Component~ReadyCallback <optional>

Ready 回调函数。

延伸

  • Component

 

成员


 静态 players :Object

全局播放器列表。

方法


 静态 getTagSettings(tag) → {Object}

获取标签设置

参数:
名称类型描述
tag Element

播放器标签

返回值:
Object - 包含播放器标签的所有设置的对象

$(selector, contextopt) → {Element|null}

查找与选择器匹配的单个DOM元素。 这可以在组件contentEl()或另一个自定义上下文中。

Parameters:
名称类型属性默认描述
selector string    

一个有效的CSS选择器,它将被传递给querySelector。

context Element | string <optional> this.contentEl()

要查询的DOM元素。 也可以是选择器字符串,在这种情况下,第一个匹配元素将用作上下文。 如果缺失则this.contentEl()被使用。 如果this.contentEl()不返回任何东西,它会回到 document。

返回值:
Element | null - 找到的dom元素,或null
继承自:
  • Component#$

$$(selector, contextopt) → {NodeList}

查找与选择器匹配的所有DOM元素。 这可以在组件contentEl()或另一个自定义上下文中。

参数:
名称类型属性默认描述
selector string    

一个有效的CSS选择器,它将被传递给 querySelectorAll.

context Element | string <optional> this.contentEl()

要查询的DOM元素。 也可以是选择器字符串,在这种情况下,第一个匹配元素将用作上下文。 如果缺失则this.contentEl()被使用。 如果this.contentEl()不返回任何东西,它会回到 document。

返回值:
NodeList - 找到的dom元素的列表
继承自:
  • Component#$$

addChild(child, optionsopt, indexopt) → {Component}

在当前组件中添加子组件。

参数:
名称
类型属性默认描述
child string | Component    

要添加的子级的名称或实例。

options Object <optional> {}

将要传递给子级的子组件选项的键/值存储。

index number <optional> this.children_.length

尝试添加子元素的索引。

返回值:
Component - 作为子项添加的组件。 当使用字符串时,组件将由此过程创建。
继承自:
  • Component#addChild

addClass(classToAdd)

    向Components元素添加CSS类名称。
参数:
名称类型描述
classToAdd string

添加的CSS类名称

继承自:
  • Component#addClass

addRemoteTextTrack(options, manualCleanupopt) → {HTMLTrackElement}

创建远程TextTrack和HTMLTrackElement。 每当源更改时,它将从视频元素中自动删除,除非manualCleanup设置为false。

参数:
名称类型属性默认描述
options Object    

在创建期间传递到HTMLTrackElement的选项。 请参阅您应该使用的对象属性的HTMLTrackElement。

manualCleanup boolean <optional> true

如果设置为false,TextTrack 不会自动删除

返回值:
HTMLTrackElement - 

已创建并添加到HTMLTrackElementList和远程TextTrackList的HTMLTrackElement

已弃用:
  • 在即将到来的Video.js版本中,“manualCleanup”参数的默认值默认为“false”

addTextTrack(kindopt, labelopt, languageopt) → {TextTrack|undefined}

用于向TextTrackList添加TextTrack的辅助方法。

除了W3C设置,我们允许通过选项添加附加信息。

参数:
名称类型属性描述
kind string <optional>

您要添加的TextTrack的类型

label string <optional>

标签给出TextTrack标签

language string <optional>

在TextTrack上设置的语言

返回值:
TextTrack | undefined - 已被添加的TextTrack或undefined (如果没有技术)

aspectRatio(ratioopt) → {string|undefined}

用于播放器宽高比的getter / setter。

参数:
名称类型属性描述
ratio string <optional>

设置播放器宽高比的值。

返回值:
string | undefined -
  • 播放器当前的纵横比,获取时
      - undefined 设置时

audioTracks() → {AudioTrackList}

获取AudioTrackList

返回值:
AudioTrackList - 

当前音轨列表

autoplay(valueopt) → {string} 

获取或设置autoplay属性。

参数:
名称类型属性描述
value boolean <optional>
  • true 表示我们应该自动播放
     - false 表示我们应该不自动播放
返回值:
string - 

获取时自动播放的当前值

blur()

从此组件中删除焦点

继承自:
  • Component#blur

buffered() → {TimeRange}

使用已下载的视频时间数组获取TimeRange对象。 如果您只想要下载的视频的百分比,请使用bufferedPercent。

返回值:
TimeRange - 模拟TimeRange对象(遵循HTML规范)

bufferedEnd() → {number}

获取上次缓冲时间范围的结束时间这在进度条中用于封装所有时间范围。

返回值:
number - 最新缓冲时间范围的结束

bufferedPercent() → {number}

获取已下载视频的百分比(十进制)。 此方法不是原生HTML video API的一部分。

返回值:
number - 0和1之间的小数表示缓冲的百分比,0是0%,1是100%

abstract(抽象修饰) buildCSSClass() → {string}

构建默认DOM类名称。 应该被子组件覆盖。

返回值:
string - 此对象的DOM类名称。
继承自:
  • Component#buildCSSClass

cancelAnimationFrame(id) → {number}

取消传递到Component#requestAnimationFrame(rAF)的排队回调。

如果您通过Component#requestAnimationFrame对rAF回调进行排队,请使用此函数,而不是window.cancelAnimationFrame。 如果没有,你的Dispose侦听器将不会被清除,直到Component#dispose!

参数:
名称类型描述
id number

要清除的rAF ID。 Component#requestAnimationFrame的返回值。

返回值:
number - 返回已清除的rAF ID。
继承自:
  • Component#cancelAnimationFrame

canPlayType(type) → {string}

检查播放器是否可以播放给定的mimetype

参数:
名称类型描述
type string

要检查的mimetype

返回值:
string - 'probably', 'maybe', or '' (empty string) - 很有可能、可能、空字符串

children() → {Array}

获取所有子组件的数组

返回值:
Array - 子组件的数组
继承自:
  • Component#children

clearInterval(intervalId) → {number}

清除通过window.setInterval或Component#setInterval创建的间隔。 如果通过组件#setInterval设置一个inteval,则使用此函数,而不是使用window.clearInterval。 如果你不这样做,你的配置侦听器将不会被清理,直到Component#dispose!

参数:
名称类型描述
intervalId number

要清除的间隔的ID。Component#setInterval或window.setInterval的返回值。

返回值:
number - 返回已清除的间隔ID。
继承自:
  • Component#clearInterval

clearTimeout(timeoutId) → {number}

清除通过window.setTimeout或Component#setTimeout创建的超时。 如果通过Component#setTimeout设置超时,则使用此函数,而不是使用window.clearTimout。 如果你不这样做,你的配置侦听器将不会被清理,直到Component#dispose!

参数:
名称类型描述
timeoutId number

要清除的超时的ID。 Component#setTimeout或window.setTimeout的返回值。

返回值:
number - 返回已清除的超时id。
继承自:
  • Component#clearTimeout

contentEl() → {Element}

返回组件DOM元素。 这是子组件插入的地方。 这通常与Component#el中返回的元素相同。

返回值:
Element - 组件的内容元素。
继承自:
  • Component#contentEl

controls(boolopt) → {boolean}

获取或设置控件是否显示。

参数:
名称类型属性描述
bool boolean <optional>
  • true 打开控制
     - false 关闭控制
触发器:
  • Player#event:controlsenabled
返回值:
boolean - 获取时controls的当前值

createEl() → {Element}

创建播放器的DOM元素。

返回值:
Element - 创建的DOM元素。
覆盖:
  • Component#createEl

createModal(content, optionsopt) → {ModalDialog}

创建一个简单的模态对话框(ModalDialog组件的一个实例),立即用任意内容覆盖播放器,并在关闭时删除它自己。

参数:
名称类型属性描述
content string | function | Element |Array | null  

与ModalDialog#content的同名参数相同。 最直接的用法是提供一个字符串或DOM元素。

options Object <optional>

将被传递到ModalDialog的额外选项。

返回值:
ModalDialog - 创建的ModalDialog

currentDimension(widthOrHeight) → {number}

获取组件元素计算样式的宽度或高度。 使用window.getComputedStyle。

参数:
名称类型描述
widthOrHeight string

包含“width”或“height”的字符串。 无论你想得到什么。

返回值:
number - 获取要求的维度,如果未为该维度设置任何内容,则为0。
继承自:
  • Component#currentDimension

currentDimensions() → {Component~DimensionObject}

获取包含组件计算样式的宽度和高度值的对象。

返回值:
Component~DimensionObject - 组件元素的尺寸
继承自:
  • Component#currentDimensions

currentHeight() → {number}

获取组件计算样式的高度。 使用window.getComputedStyle。

返回值:
number - 组件计算样式的高度。
Inherited From:
  • Component#currentHeight

currentSource() → {Tech~SourceObject}

返回当前资源对象。

返回值:
Tech~SourceObject - 当前资源对象

currentSources() → {Array.<Tech~SourceObject>}

返回所有当前资源对象。

Returns:
Array.<Tech~SourceObject> - 当前资源对象数组

currentSrc() → {string}

返回当前资源值的完全限定网址,例如 http://mysite.com/video.mp4可以与currentType结合使用,以帮助重建当前源对象。

返回值:
string - 当前资源网址

currentTime(secondsopt) → {number}

获取或设置当前时间(以秒为单位)

参数:
名称类型属性描述
seconds number | string <optional>

设置时寻找的时间,以秒为单位

返回值:
number -
  • 获取时以秒为单位的当前时间

currentType() → {string}

获取当前的资源类型,例如 video / mp4,这可以允许您重建当前源对象,以便以后可以加载相同的资源和技术

返回值:
string - 资源的MIME类型

currentWidth() → {number}

获取组件计算样式的宽度。 使用window.getComputedStyle。

返回值:
number - 组件计算样式的宽度。
继承自:
  • Component#currentWidth

defaultMuted(defaultMutedopt) → {boolean|Player}

获取当前的defaultMuted状态,或打开或关闭defaultMuted。 defaultMuted表示初始播放时静音的状态。

var myPlayer = videojs('some-player-id');

  myPlayer.src("http://www.example.com/path/to/video.mp4");

  // 获取的值为false
  console.log(myPlayer.defaultMuted());
  // 设置为true
  myPlayer.defaultMuted(true);
  // 获取的值为 true
  console.log(myPlayer.defaultMuted());
参数:
名称类型属性描述
defaultMuted boolean <optional>
  • true 设置为静音
     - false 取消静音
返回值:
boolean | Player -
  • 如果defaultMuted为on并获取,则为true
      - 如果defaultMuted为off并获取,则为false
      - 设置时引用的当前播放器

defaultPlaybackRate(rateopt) → {number|Player}

获取或设置当前默认播放速率。 例如默认回放速率1.0表示正常速度,0.5表示半速回放。 defaultPlaybackRate只会表示视频的初始playbackRate,而不是当前的playbackRate。

参数:
名称类型属性描述
rate number <optional>

要设置的新默认播放速率。

返回值:
number | Player -
  •  获取时的默认播放速率 or 1.0
      - 设置时返回播放器

dimension(dimension, valueopt) → {number} 维度

播放器宽度和高度的getter / setter。

参数:
名称类型属性描述
dimension string  

此字符串可能是:

   - 'width'
   - 'height'
value number <optional>

第一个参数中指定的维度值。

返回值:
number - 获取时制定的维度参数值 (width/height).
覆盖:
  • Component#dimension

dimensions(width, height)

同时设置Component元素的宽度和高度。

参数:
名称类型描述
width number | string

要设置的Component元素的宽度。

height number | string

要设置的Component元素的高度。

继承自:
  • Component#dimensions

dispose()

销毁视频播放器并进行任何必要的清理。

如果您要动态向DOM添加视频和从DOM中删除视频,这一点尤其有用。

触发:
  • Player#event:dispose
覆盖:
  • Component#dispose

duration(secondsopt) → {number}

通常获取视频的时间长度(以秒为单位); 除了最罕见的用例之外,参数不会被传递给方法

注意:视频必须在已知持续时间之前开始加载,对于Flash,在视频开始播放之前可能无法知道。

参数:
名称类型属性描述
seconds number <optional>

视频设置的持续时间(以秒为单位)

Fires:
  • Player#event:durationchange
返回值:
number -
  • 获取视频的时长(以秒为单位)

el() → {Element}

获取组件的的dom元素

返回值:
Element - 

The DOM element for this Component.

Inherited From:

enableTouchActivity()

此函数在触摸事件发生时报告用户活动。这可以关闭任何想要触摸事件以另外一种方式运行的子组件

触摸事件发生时报告用户触摸活动。用户活动用于确定控件何时应显示/隐藏。它是简单的,当涉及到鼠标事件,因为任何鼠标事件应该显示控件。因此,我们捕获向玩家发出的鼠标事件,并在发生时报告活动。有触摸事件它不像touchstart和touchend切换播放器控件一样简单。所以触摸事件不能帮助我们在播放器级别。

异步检查用户活动。所以可能发生的是在视频上的点击事件关闭控制。然后,touchend事件冒泡向玩家。其中,如果它报告用户活动,将重新打开控件。我们也不想完全阻止触摸事件冒泡。此外,touchmove事件和除了水龙头之外的任何东西,不应该重新打开控制。

监听下列事件:
  • Component#event:touchstart
  • Component#event:touchmove
  • Component#event:touchend
  • Component#event:touchcancel
继承自:
  • Component#enableTouchActivity

ended() → {Boolean}

返回玩家是否处于“已结束”状态。

返回值:
Boolean - 

如果玩家处于结束状态,则返回True ,否则返回false 。

enterFullWindow()

当不支持全屏时,我们可以将视频容器拉伸到浏览器允许的宽度。

Fires:
  • Player#event:enterFullWindow

error(erropt) → {MediaError|null}

设置或获取当前的MediaError

参数:
名称类型属性描述
err MediaError | string | number <optional>

MediaError或要变成MediaError的字符串/数字

Fires:
  • Player#event:error
返回值:
MediaError | null - 

当获取时的当前MediaError(或null)

exitFullscreen()

在全屏模式后,将视频恢复到正常大小

Fires:
  • Player#event:fullscreenchange

exitFullWindow()

退出全窗口模式

Fires:
  • Player#event:exitFullWindow

flexNotSupported_() → {boolean}

确定是否支持flexbox

返回值:
boolean -
  • true 如果支持flexbox
      - false 如果不支持flexbox

fluid(boolopt) → {boolean|undefined}

Player上的vjs-fluid className的getter / setter / toggler。

参数:
名称类型属性描述
bool boolean <optional>
  • 值为 true 则添加此calss.
     -值为 false 则移除此 class.
     - 没有值将toggle the fluid class.
返回值:
boolean | undefined -
  • The value of fluid when getting.
      - `undefined` when setting.

focus()

将焦点设置到此组件

Inherited From:
  • Component#focus

fullWindowOnEscKey(event)

在ESC键上检查呼叫是退出完整窗口还是全屏

参数:
名称类型描述
event string

Event to check for key press

getAttribute(attribute) → {string|null}

获取Components元素上的属性值。

参数:
名称类型描述
attribute string

要获取值的属性的名称。

返回值:
string | null -
  • 要求的属性的值。
      - 如果该属性不存在或没有值,则可能是某些浏览器上的空字符串
      - 如果属性不存在或没有值,大多数浏览器将返回null。
Inherited From:
  • Component#getAttribute
See:
  • DOM API

getCache() → {Object}

获取缓存值的对象。

返回值:
Object - 

获取当前对象缓存

getChild(name) → {Component|undefined}

返回具有给定名称的子组件。

参数:
名称类型描述
name string

要获取的子组件的名称。

返回值:
Component | undefined - 

具有给定名称的子组件或未定义。

Inherited From:
  • Component#getChild

getChildById(id) → {Component|undefined}

返回具有给定ID的子组件。

参数:
名称类型描述
id string

要获取的子组件的id。

返回值:
Component | undefined - 

给定id的自组建或者undefined

Inherited From:
  • Component#getChildById

hasClass(classToCheck) → {boolean}

检查组件的元素是否具有CSS类名称。

参数:
名称类型描述
classToCheck string

要检查的CSS类名称。

返回值:
boolean -
  • True if the Component has the class.
      - False if the `Component` does not have the class`
Inherited From:
  • Component#hasClass

hasPlugin(name) → {boolean}

报告播放器是否有可用的插件。

这里不报告插件是否已经在这个播放器上被初始化了。 为此,usingPlugin。

参数:
名称类型描述
name string

插件的名称。

返回值:
boolean - 

该播放器是否具有可用的请求插件。

hasStarted(hasStarted) → {boolean}

Add/remove the vjs-has-started class

参数:
名称类型描述
hasStarted boolean
  • true: adds the class
     - false: remove the class
Fires:
  • Player#event:firstplay
返回值:
boolean - 

the boolean value of hasStarted

height(valueopt) → {number}

A getter/setter for the Player's height.

参数:
名称类型属性描述
value number <optional>

The value to set the `Player's heigth to.

返回值:
number - 

The current height of the Player when getting.

Overrides:
  • Component#height

hide()

Hide the Components element if it is currently showing by adding the 'vjs-hidden` class name to it.

Inherited From:
  • Component#hide

id() → {string}

Get this Components ID

返回值:
string - 

The id of this Component

Inherited From:
  • Component#id

initChildren()

根据选项添加和初始化默认的子组件。

Inherited From:
  • Component#initChildren

isAudio(bool) → {boolean}

Gets or sets the audio flag

参数:
名称类型描述
bool boolean
  • true signals that this is an audio player
     - false signals that this is not an audio player
返回值:
boolean - 

The current value of isAudio when getting

isFullscreen(isFSopt) → {boolean}

检查播放器是否处于全屏模式,或者告诉播放器它是或不是全屏模式。

注意:根据最新的HTML5规范,isFullscreen不再是官方属性,而是使用document.fullscreenElement。 但isFullscreen仍然是内部播放器运行的有价值的属性。

参数:
名称类型属性描述
isFS boolean <optional>

设置播放器当前的全屏状态

返回值:
boolean -
  • true 如果全屏是开启的并且获取时
      - false 如果全屏是关闭的并且获取时

language(codeopt) → {string}

 

The player's language code NOTE: The language should be set in the player options if you want the the controls to be built with a specific language. Changing the lanugage later will not update controls text.

参数:
名称类型属性描述
code string <optional>

the language code to set the player to

返回值:
string - 

The current language code when getting

languages() → {Array}

 

Get the player's language dictionary Merge every time, because a newly added plugin might call videojs.addLanguage() at any time Languages specified directly in the player options have precedence

返回值:
Array - 

An array of of supported languages

load()

 

Begin loading the src data.

localize(string) → {string}

 

Localize a string given the string in english.

参数:
名称类型描述
string string

The string to localize.

返回值:
string - 

The localized string or if no localization exists the english string.

Inherited From:

loop(valueopt) → {string}

 

Get or set the loop attribute on the video element.

参数:
名称类型属性描述
value boolean <optional>
  • true means that we should loop the video
     - false means that we should not loop the video
返回值:
string - 

The current value of loop when getting

muted(mutedopt) → {boolean}

 

Get the current muted state, or turn mute on or off

参数:
名称类型属性描述
muted boolean <optional>
  • true to mute
     - false to unmute
返回值:
boolean -
  • true if mute is on and getting
      - false if mute is off and getting

name() → {string}

 

Get the Components name. The name gets used to reference the Component and is set during registration.

返回值:
string - 

The name of this Component.

Inherited From:

networkState() → {number}

 

从以下列表中的代码返回元素的网络活动的当前状态。

  • NETWORK_EMPTY (numeric value 0) 元素尚未初始化, 所有属性都处于初始状态。
  • NETWORK_IDLE (numeric value 1) 元素的资源选择算法处于活动状态,并且已经选择了一个资源,但此时并不实际使用该网络。
  • NETWORK_LOADING (numeric value 2) 用户代理正在积极尝试下载数据。
  • NETWORK_NO_SOURCE (numeric value 3) 元素的资源选择算法处于活动状态,但尚未找到要使用的资源。
返回值:
number - 

当前网络活动状态

options(obj) → {Object}

 

Deep merge of options objects with new options.

Note: When both obj and options contain properties whose values are objects. The two properties get merged using module:mergeOptions

参数:
名称类型描述
obj Object

The object that contains new options.

返回值:
Object - 

A new object of this.options_ and obj merged together.

Inherited From:
Deprecated:
  • since version 5

pause() → {Player}

 

Pause the video playback

返回值:
Player - 

A reference to the player object this function was called on

paused() → {boolean}

 

Check if the player is paused or has yet to play

返回值:
boolean -
  • false: if the media is currently playing
      - true: if media is not currently playing

play() → {Promise|undefined}

 

start media playback

返回值:
Promise | undefined - 

Returns a Promise if the browser returns one, for most browsers this will return undefined.

playbackRate(rateopt) → {number}

 

Gets or sets the current playback rate. A playback rate of 1.0 represents normal speed and 0.5 would indicate half-speed playback, for instance.

参数:
名称类型属性描述
rate number <optional>

New playback rate to set.

返回值:
number - 

The current playback rate when getting or 1.0

See:

played() → {TimeRange}

 

Get a TimeRange object representing the current ranges of time that the user has played.

返回值:
TimeRange - 

A time range object that represents all the increments of time that have been played.

player() → {Player}

 

Return the Player that the Component has attached to.

返回值:
Player - 

The player that this Component has attached to.

Inherited From:

poster(srcopt) → {string}

 

Get or set the poster image source url

参数:
名称类型属性描述
src string <optional>

Poster image source URL

Fires:
返回值:
string - 

The current value of poster when getting

preload(valueopt) → {string}

获取或设置preload属性

参数:
名称类型属性描述
value boolean <optional>
  • true 意味着要预加载
     - false 意味着不需要预加载
返回值:
string - 

获取时的preload属性值

ready() → {Component}

将侦听器绑定到组件的就绪状态。 与事件侦听器不同的是,如果ready事件已经发生,它将立即触发该功能。

返回值:
Component - 

返回自己; 方法可以链接。

Inherited From:
  • Component#ready

readyState() → {number}

从下面的列表中的代码返回一个值,表示当前呈现当前播放位置的元素的当前状态。

HAVE_NOTHING(数值0)没有关于媒体资源的信息可用。
HAVE_METADATA(数值1)已获得足够的资源,资源的持续时间可用。
HAVE_CURRENT_DATA(数值2)即时当前播放位置的数据可用。
HAVE_FUTURE_DATA(数值3)即时当前播放位置的数据可用,以及足够的数据供用户代理在播放方向上提前播放当前位置。
HAVE_ENOUGH_DATA(数值4)用户代理估计足够的数据可用于播放以不间断地继续。

  • HAVE_NOTHING(数值0)没有关于媒体资源的信息可用。
  • HAVE_METADATA(数值1)已获得足够的资源,资源的持续时间可用。
  • HAVE_CURRENT_DATA (数值 2) 当前播放位置的即时数据可用。
  • HAVE_FUTURE_DATA (数值 3) 当前播放位置的即时数据可用, 以及足够的数据供用户代理在播放方向上提前播放当前位置。
  • HAVE_ENOUGH_DATA (数值 4) 用户代理估计足够的数据可用于播放以不间断地继续。
返回值:
number - 

当前播放渲染状态

See:

remainingTime() → {number}

计算视频中剩余多少时间。 不是原生视频API的一部分。

返回值:
number - 

剩余时间以秒为单位

remoteTextTrackEls() → {HTMLTrackElementList}

 

Get the remote HTMLTrackElementList tracks.

返回值:
HTMLTrackElementList - 

The current remote text track element list

removeAttribute(attribute)

 

Remove an attribute from the Components element.

参数:
名称类型描述
attribute string

Name of the attribute to remove.

Inherited From:
See:

removeChild(component)

 

Remove a child Component from this Components list of children. Also removes the child Components element from this Components element.

参数:
名称类型描述
component Component

The child Component to remove.

Inherited From:

removeClass(classToRemove)

 

Remove a CSS class name from the Components element.

参数:
名称类型描述
classToRemove string

CSS class name to remove

Inherited From:

removeRemoteTextTrack(track) → {undefined}

 

Remove a remote TextTrack from the respective TextTrackList and HTMLTrackElementList.

参数:
名称类型描述
track Object

Remote TextTrack to remove

返回值:
undefined - 

does not return anything

reportUserActivity(event)

 

Report user activity

参数:
名称类型描述
event Object

Event object

requestAnimationFrame(fn) → {number}

 

Queues up a callback to be passed to requestAnimationFrame (rAF), but with a few extra bonuses:

  • Supports browsers that do not support rAF by falling back to Component#setTimeout.

  • The callback is turned into a Component~GenericCallback (i.e. bound to the component).

  • Automatic cancellation of the rAF callback is handled if the component is disposed before it is called.

参数:
名称类型描述
fn Component~GenericCallback

A function that will be bound to this component and executed just before the browser's next repaint.

Listens to Events:
返回值:
number - 

Returns an rAF ID that gets used to identify the timeout. It can also be used in Component#cancelAnimationFrame to cancel the animation frame callback.

Inherited From:
See:

requestFullscreen()

将视频的大小增加到全屏在某些浏览器中,全屏不被原生支持,因此进入“完整窗口模式”,视频填充浏览器窗口。 在支持原生全屏的浏览器和设备中,有时会显示浏览器的默认控件,而不是Video.js的自定义外观。 这包括大多数移动设备(iOS,Android)和较旧版本的Safari。

Fires:
  • Player#event:fullscreenchange

reset()

重置播放器. 加载techOrder的第一个技术,并且调用tech上的重置

scrubbing(isScrubbingopt) → {boolean}

返回用户是否正在“擦除”。 擦洗是当用户点击进度条手柄并沿着进度条拖动时。

参数:
名称类型属性描述
isScrubbing boolean <optional>

用户是否擦除

返回值:
boolean - 

获取时scrubbing的值

seekable() → {TimeRanges}

返回当前可用于寻找的媒体的TimeRanges。

返回值:
TimeRanges - 

媒体时间轴的可寻找间隔

seeking() → {Boolean}

返回玩家是否处于“寻求”状态。

返回值:
Boolean - 

如果玩家处于寻求状态,则为真,否则为假。

selectSource(sources) → {Object|boolean}

Select source based on tech-order or source-order Uses source-order selection if options.sourceOrder is truthy. Otherwise, defaults to tech-order selection

参数:
名称类型描述
sources Array

The sources for a media asset

返回值:
Object | boolean - 

Object of source and tech order or false

setAttribute(attribute, value)

Set the value of an attribute on the Component's element

参数:
名称类型描述
attribute string

Name of the attribute to set.

value string

Value to set the attribute to.

Inherited From:
See:

setInterval(fn, interval) → {number}

创建一个每x毫秒运行的函数。 这个函数是一个围绕window.setInterval的包装器。 用这个函数代替有以下原因。

  1. 当Component#dispose被调用时,它通过Component#clearInterval清除。
  2. 函数回调将是一个Component〜GenericCallback
参数:
名称类型描述
fn Component~GenericCallback

每x秒运行一次的函数。

interval number

每x毫秒执行指定的函数。

Listens to Events:
  • Component#event:dispose
返回值:
number - 

返回可用于标识interval的ID。 也可以在Component#clearInterval中使用它来清除间隔

Inherited From:
  • Component#setInterval

setTimeout(fn, timeout) → {number}

Creates a function that runs after an x millisecond timeout. This function is a wrapper around window.setTimeout. There are a few reasons to use this one instead though:

创建在x毫秒超时后运行的函数。 这个函数是一个围绕window.setTimeout的包装器。 使用这个函数的一些原因:

  1.  当Component#dispose被调用时,它通过Component#clearTimeout清除。
  2. 函数回调将变成一个Component〜GenericCallback

注意:您可以在此函数返回的id上使用window.clearTimeout。 这将使其dispose listene不被清理! 请使用Component#clearTimeout或Component#dispose。

参数:
名称类型描述
fn Component~GenericCallback

超时后运行的函数。

timeout number

在执行指定功能之前延迟(以毫秒为单位)。

Listens to Events:
  • Component#event:dispose
返回值:
number - 

返回用于标识超时的超时ID。 它也可以在Component#clearTimeout中使用,以清除设置的超时。

Inherited From:
  • Component#setTimeout

show()

 

Show the Components element if it is hidden by removing the 'vjs-hidden' class name from it.

Inherited From:

src(sourceopt) → {string}

 

The source function updates the video source There are three types of variables you can pass as the argument. URL string: A URL to the the video file. Use this method if you are sure the current playback technology (HTML5/Flash) can support the source you provide. Currently only MP4 files can be used in both HTML5 and Flash.

参数:
名称类型属性描述
source Tech~SourceObject | Array.<Tech~SourceObject> <optional>

One SourceObject or an array of SourceObjects

返回值:
string - 

The current video source when getting

supportsFullScreen() → {boolean}

检查当前的技术可以支持原生的全屏(例如,内置的控件,如iOS,所以不是我们的Flash swf)

返回值:
boolean - 

if native fullscreen is supported

tech(safetyopt) → {Tech}

Return a reference to the current Tech. It will print a warning by default about the danger of using the tech directly but any argument that is passed in will silence the warning.

参数:
名称类型属性描述
safety * <optional>

Anything passed in to silence the warning

返回值:
Tech - 

The Tech

textTracks() → {TextTrackList}

 

Get the TextTrackList

返回值:
TextTrackList - 

the current text track list

textTracks() → {TextTrackList}

 

Get the remote TextTrackList

返回值:
TextTrackList - 

The current remote text track list

toggleClass(classToToggle, predicateopt)

 

Add or remove a CSS class name from the component's element.

参数:
名称类型属性描述
classToToggle string  

The class to add or remove based on (@link Component#hasClass}

predicate boolean | Dom~predicate <optional>

An Dom~predicate function or a boolean

Inherited From:

toJSON() → {Object}

 

returns a JavaScript object reperesenting the current track information. DOES not return it as JSON

返回值:
Object - 

Object representing the current of track info

triggerReady()

触发此组件的所有就绪侦听器。

发起:
  • Component#event:ready
继承自:
  • Component#triggerReady

userActive(boolopt) → {boolean}

 

Get/set if user is active

参数:
名称类型属性描述
bool boolean <optional>
  • true if the user is active
     - false if the user is inactive
Fires:
返回值:
boolean - 

The current value of userActive when getting

usingNativeControls(boolopt) → {boolean}

 

Toggle native controls on/off. Native controls are the controls built into devices (e.g. default iPhone controls), Flash, or other techs (e.g. Vimeo Controls) This should only be set by the current tech, because only the tech knows if it can support native controls

参数:
名称类型属性描述
bool boolean <optional>
  • true to turn native controls on
     - false to turn native controls off
Fires:
返回值:
boolean - 

The current value of native controls when getting

usingPlugin(name) → {boolean}

 

Reports whether or not a player is using a plugin by name.

For basic plugins, this only reports whether the plugin has ever been initialized on this player.

参数:
名称类型描述
name string

The name of a plugin.

返回值:
boolean - 

Whether or not this player is using the requested plugin.

videoHeight() → {number}

 

Get video height

返回值:
number - 

current video height

videoTracks() → {VideoTrackList}

 

Get the VideoTrackList

返回值:
VideoTrackList - 

the current video track list

videoWidth() → {number}

Get video width

返回值:
number - 

current video width

volume(percentAsDecimalopt) → {number}

Get or set the current volume of the media

参数:
名称类型属性描述
percentAsDecimal number <optional>

The new volume as a decimal percent:

    - 0 is muted/0%/off
    - 1.0 is 100%/full
    - 0.5 is half volume or 50%
返回值:
number - 

The current volume as a percent when getting

width(valueopt) → {number}

A getter/setter for the Player's width.

参数:
名称类型属性描述
value number <optional>

The value to set the `Player's width to.

返回值:
number - 

The current width of the Player when getting.

Overrides:
  • Component#width

事件

abort

当音频/视频的加载中止时触发。

类型:
  • EventTarget~Event

canplay

媒体具有 HAVE_FUTURE_DATA 或更大的readyState。

类型:
  • EventTarget~Event

canplaythrough

媒体具有HAVE_ENOUGH_DATA或更大的readyState。 这意味着整个媒体文件可以无缓冲播放。

类型:
  • EventTarget~Event

componentresize

调整组件大小时触发。

类型:
  • EventTarget~Event
继承自:
  • Component#event:componentresize

controlsdisabled

   控制条禁用时触发。

类型:
  • EventTarget~Event

controlsenabled

     控制条启用时触发。

类型:
  • EventTarget~Event

dispose

播放器被销毁时调用。

类型:
  • EventTarget~Event
此事件的监听器:
  • Plugin
覆盖:
  • Component#event:dispose

durationchange

   播放时长被更改时调用。

类型:
  • EventTarget~Event
此事件的监听器:
  • DurationDisplay#updateContent
  • LiveDisplay#updateShowing
  • RemainingTimeDisplay#updateContent

emptied

当前播放列表为空时触发。

类型:
  • EventTarget~Event

ended

当媒体资源结束时触发 (currentTime == duration)

类型:
  • EventTarget~Event
此事件监听器:
  • SeekBar#update

enterFullWindow

   当运行enterFullWindow(浏览器不支持全屏时的全屏)方法时触发

类型:
  • EventTarget~Event

error

   发生错误是触发

类型:
  • EventTarget~Event

exitFullWindow

   当运行enterFullWindow(浏览器不支持全屏时的退出全屏)方法时触发,

类型:
  • EventTarget~Event

firstplay

首次播放视频时触发。 不是HLS规范的一部分,并且这可能不是最好的实现,所以使用谨慎。 如果你没有理由阻止播放,使用 myPlayer.one('play'); 代替。

类型:
  • EventTarget~Event

fullscreenchange

   在进入和退出全屏时触发。 

类型:
  • EventTarget~Event
此事件的监听器:
  • FullscreenToggle#handleFullscreenChange
  • TextTrackDisplay#updateDisplay

loadeddata

当播放器已在当前播放位置数据加载完后时触发。

类型:
  • EventTarget~Event

loadedmetadata

浏览器加载完成音频/视频的元数据时触发。(播放器获取初始持续时间和尺寸信息)

类型:
  • EventTarget~Event
此事件的监听器:
  • DurationDisplay#updateContent

loadstart

当用户代理开始查找媒体数据时触发。

类型:
  • EventTarget~Event
此事件监听器:
  • MuteToggle#update
  • PlaybackRateMenuButton#updateVisibility
  • TextTrackDisplay#toggleDisplay

pause

每当媒体暂停时触发

类型:
  • EventTarget~Event
此事件的监听器:
  • PlayToggle#handlePause

play

每当发生Tech#play事件时触发。 表示播放已开始或恢复。

类型:
  • EventTarget~Event
此事件的监听器:
  • PlayToggle#handlePlay

playing

媒体不再被阻止播放,并已开始播放。

类型:
  • EventTarget~Event

pluginsetup

表示插件刚刚在播放器上设置。

类型:
  • Plugin~PluginEventHash

posterchange

当海报图片在播放器上更改时,此事件触发。

类型:
  • EventTarget~Event
此事件的监听器:
  • PosterImage#update

progress

在用户代理正在下载媒体数据时触发。

类型:
  • EventTarget~Event
此事件的监听器:
  • LoadProgressBar#update

ready

组件准备就绪时触发。

类型:
  • EventTarget~Event
继承自:
  • Component#event:ready

resize

视频的内部尺寸更改时触发。

类型:
  • event

seeked

当播放器完成跳跃到新的时间时触发

类型:
  • EventTarget~Event

seeking :寻找

当播放器跳到新的时间时触发

类型:
  • EventTarget~Event

stalled :停顿

在浏览器尝试获取媒体数据时触发,但数据不可用。

类型:
  • EventTarget~Event

suspend :中断

当浏览器故意未获取媒体数据时触发。

类型:
  • EventTarget~Event

tap

当组件被点击时触发。

类型:
  • EventTarget~Event
继承自:
  • Component#event:tap

textdata

当我们从tech获取textdata事件时触发

类型:
  • EventTarget~Event

timeupdate

当前播放位置已更改时触发。在播放期间,每15 - 250毫秒触发一次,具体取决于使用的播放技术。

类型:
  • EventTarget~Event
此事件的监听器:
  • CurrentTimeDisplay#updateContent
  • DurationDisplay#updateContent
  • RemainingTimeDisplay#updateContent
  • SeekBar#update

useractive

    用户活动时触发
类型:
  • EventTarget~Event

userinactive

    用户不活动时触发
类型:
  • EventTarget~Event

usingcustomcontrols

播放器正在使用自定义HTML控件时触发

类型:
  • EventTarget~Event

usingnativecontrols

播放器正在使用本地设备控件时触发

类型:
  • EventTarget~Event

volumechange

音量更改时触发

类型:
  • EventTarget~Event
此事件的监听器:
  • MuteToggle#update
  • VolumeBar#updateARIAAttributes

waiting

DOM元素上的readyState更改已导致播放停止。

类型:
  • EventTarget~Event

如果属性不存在或没有值,大多数浏览器将返回null。

原文地址:https://www.cnblogs.com/nightstarsky/p/6518668.html