嗜睡是什么原因| 吃天麻对身体有什么好处| 血压低头晕是什么原因导致的| 脾虚湿蕴证是什么意思| 来大姨妈吃什么水果好| 胃胀是什么原因导致的| 12月31号什么星座| 什么原因不来月经| 血糖高喝什么牛奶好| 五什么四什么| 怕得什么| msi是什么意思| 尿黄什么原因| 兔子可以吃什么蔬菜| 贵阳有什么特产| 拉肚子能吃什么| 油边是什么肉| 武的部首是什么| 喝酒前吃什么药| 梦见茄子是什么意思| 龟裂是什么意思| 购物狂是什么心理疾病| 胃疼胃胀用什么药效果最好| 上面一个山下面一个今读什么| 优甲乐过量有什么症状| 牡丹花什么颜色| 茶色尿液提示什么病| 心肌桥是什么意思| 那个叫什么| 中耳炎是什么症状| 脚裂口子是什么原因| 368什么意思| 医院有什么科室| 热射病是什么病| 芝兰是什么意思| 心肌缺血吃什么| 手足口病疫苗什么时候打| mua什么意思| 白醋洗脸有什么效果| m代表什么单位| 什么生花| 献血有什么危害| 心慌气短是什么原因| 精液长什么样| 血清高是什么原因| 为什么血是红色的| cco是什么意思| 姑奶奶的老公叫什么| 为什么不能天天做有氧运动| 茉莉茶属于什么茶| calcium是什么意思| 拉屎像拉水一样为什么| 右肺下叶纤维化灶是什么意思| 静脉曲张是什么原因引起的| 双喜临门是什么生肖| af什么意思| 情感障碍是什么意思| 什么叫五官| 吃什么养肝护肝效果最好| 卢森堡为什么那么有钱| 冰冻三尺的下一句是什么| 百合花什么颜色| 原生家庭什么意思| kbs是什么意思| 左边是心脏右边是什么| 肾萎缩是什么原因引起的| 周中是什么意思| 海员是干什么的| 七七事变是什么生肖| ur是什么| 做脑部检查挂什么科| 醋粉是什么做的| 梦见怀孕的女人是什么意思| 洗澡有什么好处| 说一个人轴是什么意思| 小猫发烧有什么症状| 脚上起水泡用什么药膏| 治疗结石最好的方法是什么| 猪八戒的武器叫什么| 外阴苔癣是一种什么病| 9月15号是什么日子| 害怕是什么意思| 岔气是什么意思| 扎巴依是什么意思| 蝙蝠来家里是什么预兆| 孕期能吃什么| 倾慕是什么意思| 手机暂停服务是什么意思| 吃素是什么意思| 低血糖吃什么| 阻滞是什么意思| 水泻拉肚子是什么原因| 什么是高筋面粉| 自负是什么意思| 霍家为什么娶郭晶晶| 喉咙嘶哑是什么原因| 烂漫什么意思| 梦见蛇是什么意思| 什么叫阳性| 运动喝什么水补充能量| 七七事变是什么生肖| 酉读什么| 打豆豆什么意思| 女生月经迟迟不来是什么原因| 夫妻肺片里面都有什么| 肚子为什么胀气| 煲什么汤含蛋白质高| y代表什么意思| 圣诞礼物什么时候送| 升白针是什么药| 桥本氏甲状腺炎是什么意思| 传奇是什么意思| 手蜕皮什么原因| 冒菜和麻辣烫有什么区别| 薛之谦为什么离婚| 猕猴桃树长什么样| 上面白下面本念什么| 早上起来口苦吃什么药| 润滑油是什么| 胰腺最怕什么| 可乐饼为什么叫可乐饼| 指腹脱皮是什么原因| 南京大屠杀是什么时候| 酒蒙子是什么意思| 血糖低吃什么补得最快| 渗液是什么意思| 女人右眼跳是什么预兆| 心跳加速心慌吃什么药| 让心归零是什么意思| 梦见黑山羊是什么预兆| 舌根发硬是什么原因| 梦见打仗是什么意思| 屏气是什么意思| 血管瘤是什么症状| 亡羊补牢说明什么道理| 蛋白粉什么时候吃最好| 小便失禁是什么原因男性| 花非花雾非雾什么意思| 牛男和什么属相最配| 鳞状上皮细胞高是什么原因| 龙头龟身是什么神兽| 农业户口和非农业户口有什么区别| 市公安局长什么级别| 神经衰弱吃什么药| 项羽是什么生肖| 眼镜框什么材质的好| 大姨妈来了喝红糖水有什么功效| 光是什么生肖| 男人前列腺炎有什么症状表现| 备皮什么意思| 绿对什么| 1968年猴是什么命| 河粉是什么做的| boq是什么意思| 疱疹用什么药膏| 什么叫裸眼视力| 女人梦见狗是什么预兆| 见利忘义是什么意思| 细小是什么病什么症状| 热能是什么| 滋味是什么意思| 经常反义词是什么| 女人更年期是什么症状| 右胸是什么器官| 月子里生气有什么危害| 女人为什么会叫| 尽形寿是什么意思| 射手什么象星座| 地球是什么生肖| 吐槽是什么意思| 7月23日什么星座| 腰膝酸软是什么症状| 发好人卡是什么意思| 宁属于五行属什么| 荷叶和什么搭配最减肥| 梦到装修房子是什么征兆| 为什么会得荨麻疹呢| 夜尿频繁是什么原因| 血沉是查什么| 疖子是什么原因引起的| 心得安又叫什么名| 羽字五行属什么的| 睡觉打呼噜是什么病| 什么病不能吃秋葵| 孩子呕吐是什么原因| 无水酥油是什么| 什么叫菩提心| 卒中是什么意思| 什么颜薄命| 手舞足蹈是什么生肖| 叶酸是什么东西| 10月30号什么星座| 二氧化硅是什么东西| 泡沫尿吃什么药| mint什么颜色| 胃动力不足是什么原因造成的| 透析什么意思| 直博生是什么意思| npn是什么意思| 爬金字塔为什么会死| 茄子吃了有什么好处| 什么的月光| 梦到被狗咬是什么意思| 四大皆空是指什么| 查心电图挂什么科| lalabobo是什么牌子| 颠鸾倒凤什么意思| 下午七点是什么时辰| 对什么有益英语| 胃胀不舒服吃什么药| mcm是什么牌子| 路人皆知的上一句歇后语是什么| 怀孕一个星期有什么症状| 狗尾续貂什么意思| 晚上蝴蝶来家什么预兆| 虾皮是什么| 小产吃什么好恢复营养| 嘴角烂了是什么原因| 十二月二十三是什么星座| 车前草的作用是什么| mono是什么意思| 女人梦到地震预示什么| 吃菠萝蜜有什么好处| 健脾去湿吃什么药| 拉肚子吃什么药| 晞字五行属什么| 十月七号什么星座| 支气管炎改变什么意思| 什么的大叫| 脂肪肝是什么病| lime是什么水果| 边缘视力是什么意思| 宝格丽手表什么档次| 美人尖是什么意思| 冬虫夏草是什么东西| 公积金缴存基数什么意思| 桑叶有什么作用和功效| gr是什么元素| 支付宝余额和余额宝有什么区别| 重阳节的习俗是什么| 吃深海鱼油有什么好处和坏处| 梦见桥断了是什么意思| 留置针是什么| 蛇进家是什么意思| 为什么不要看电焊火花| 什么时候怀孕几率最高| 高铁上什么东西不能带| 孩子感冒咳嗽吃什么药| hpv病毒是什么| crp是什么意思| 喝黑枸杞有什么作用和功效| 结缡什么意思| 致五行属什么| 拉肚子吃什么最好| 西南方是什么生肖| elsa是什么意思| 文胸是什么意思| 女生肚脐眼下面疼是什么原因| 放大镜是什么镜| 北京友谊医院擅长什么| 读军校需要什么条件| 蚂蚁为什么会咬人| 山药炖什么好吃| 吃什么去肝火| 百度

浙江好项目·2017中小微企业创新创业大赛今天启动

Video.js Guides

百度 确定没人发现后,他便联系卖家,装作一副受害者的模样,找卖家索赔。

These guides cover a range of topics for users of Video.js

Components

NOTE: This guide is focused on Video.js 8+. It no longer mentions use of the videojs.extend() method, which was removed in 8.0. Please see our migration guide for further information!

The architecture of the Video.js player is centered around components.

The Player class and all classes representing player controls and other UI elements inherit from the Component class. This architecture makes it easy to construct the user interface of the Video.js player in a tree-like structure that mirrors the DOM.

What is a Component?

A component is a JavaScript object that has the following features:

  • An associated DOM element, in almost all cases.
  • An association to a Player object.
  • The ability to manage any number of child components.
  • The ability to listen for and trigger events.
  • A lifecycle of initialization and disposal.

For more specifics on the programmatic interface of a component, see the component API docs.

Adding a Component

An instance of a component can be created with new Component().

// Creating an instance of a button
var player = videojs('some-video-id');
var Button = videojs.getComponent('Button');
var button = new Button(player, {
  clickHandler: function(event) {
    videojs.log('Clicked');
  }
});

console.log(button.el());

The above code will output

<button class="vjs-control vjs-button" type="button" aria-disabled="false">
  <span class="vjs-icon-placeholder" aria-hidden="true"></span>
  <span class="vjs-control-text" aria-live="polite"></span>
</button>

Note that this has created the button, but not added it to the DOM. Adding it as a child of a component will add it to the DOM.

player.getChild('ControlBar').addChild(button);

Alternatively by passing the name of a component to addChild, a new instance of the component will be created and added in one step.

// Creating an instance of a button and addingit to the player's control bar
var player = videojs('some-video-id');
var button = player.getChild('ControlBar').addChild('button', {
  clickHandler: function(event) {
    videojs.log('Clicked');
  }
});

console.log(button.el());
// will have the same html result as the previous example

Buttons should have text. The default buttons don't display their text, but it is present for screenreaders and displayed by browsers as a tooltip. The text of the button can be set as an option:

const myButton = player.getChild('ControlBar').addChild('button', {controlText: 'My button'});

To have the control text displayed, add a vjs-visibile-text class to the button.

const myButton = player.getChild('ControlBar').addChild('button', {
  controlText: 'My button',
  className: 'vjs-visible-text'
});

Classes and control text could also be set after a button is created.

myButton.controlText('My button');
myButton.addClass('vjs-visible-text');

When the experimentalSvgIcons option is enabled on the player, icons can be added or replaced on any Component using the setIcon method.

You can view all of the icons available by renaming sandbox/svg-icons.html.example to sandbox/svg-icons.html, building Video.js with npm run build, and opening sandbox/svg-icons.html in your browser of choice.

myButton.setIcon('play');

Creating a Component

Video.js components are es6 classes that can be extended using class syntax and registered with Video.js to add new features and UI to the player.

There are a few functions used for creating and registering components:

  • videojs.getComponent(String name): Retrieves component classes from Video.js.
  • videojs.registerComponent(String name, Function Comp): Registers component classes with Video.js.

This example creates a title bar component, as a class extending Component.

// Get the Component base class from Video.js
const Component = videojs.getComponent('Component');

class TitleBar extends Component {

  // The constructor of a component receives two arguments: the
  // player it will be associated with and an object of options.
  constructor(player, options = {}) {

    // It is important to invoke the superclass before anything else, 
    // to get all the features of components out of the box!
    super(player, options);

    // If a `text` option was passed in, update the text content of 
    // the component.
    if (options.text) {
      this.updateTextContent(options.text);
    }
  }

  // The `createEl` function of a component creates its DOM element.
  createEl() {
    return videojs.dom.createEl('div', {

      // Prefixing classes of elements within a player with "vjs-" 
      // is a convention used in Video.js.
      className: 'vjs-title-bar'
    });
  }

  // This function could be called at any time to update the text 
  // contents of the component.
  updateTextContent(text) {

    // If no text was provided, default to "Title Unknown"
    if (typeof text !== 'string') {
      text = 'Title Unknown';
    }

    // Use Video.js utility DOM methods to manipulate the content
    // of the component's element.
    videojs.emptyEl(this.el());
    videojs.appendContent(this.el(), text);
  }
}

Note that due to the removal of the extend() function, to extend a component when transpiling to ES5, you will need to utilize the following syntax.

// My ES5 constructor function extending Component
function MyComponent(arguments) {
  Component.call(this, arguments);
}

MyComponent.prototype = Object.create(Component.prototype);

Once the component is created, it can be registered, and used in a player.

// Register the component with Video.js, so it can be used in players.
videojs.registerComponent('TitleBar', TitleBar);

// Create a player.
var player = videojs('my-player');

// Add the TitleBar as a child of the player and provide it some text 
// in its options.
player.addChild('TitleBar', {text: 'The Title of The Video!'});

A live example is in this JSBin.

Component Children

Again, refer to the component API docs for complete details on methods available for managing component structures.

Basic Example

When a child component is added to a parent component, Video.js inserts the element of the child into the element of the parent. For example, adding a component like this:

// Add a "BigPlayButton" component to the player. Its element will be appended to the player's element.
player.addChild('BigPlayButton');

Results in a DOM that looks like this:

<!-- Player Element -->
<div class="video-js">
  <!-- BigPlayButton Element -->
  <div class="vjs-big-play-button"></div>
</div>

Conversely, removing child components will remove the child component's element from the DOM:

player.removeChild('BigPlayButton');

Results in a DOM that looks like this:

<!-- Player Element -->
<div class="video-js">
</div>

Using Options

Pass in options for child constructors and options for children of the child.

var player = videojs('some-vid-id');
var Component = videojs.getComponent('Component');
var myComponent = new Component(player);
var myButton = myComponent.addChild('MyButton', {
  text: 'Press Me',
  buttonChildExample: {
    buttonChildOption: true
  }
});

Children can also be added via options when a component is initialized.

Note: Include a 'name' key which will be used if two child components of the same type that need different options.

// MyComponent is from the above example
var myComp = new MyComponent(player, {
  children: ['button', {
    name: 'button',
    someOtherOption: true
  }, {
    name: 'button',
    someOtherOption: false
  }]
});

Event Listening

Using on

var player = videojs('some-player-id');
var Component = videojs.getComponent('Component');
var myComponent = new Component(player);
var myFunc = function() {
  var myComponent = this;
  console.log('myFunc called');
};

myComponent.on('eventType', myFunc);
myComponent.trigger('eventType');
// logs 'myFunc called'

The context of myFunc will be myComponent unless it is bound. You can add a listener to another element or component.

var otherComponent = new Component(player);

// myComponent/myFunc is from the above example
myComponent.on(otherComponent.el(), 'eventName', myFunc);
myComponent.on(otherComponent, 'eventName', myFunc);

otherComponent.trigger('eventName');
// logs 'myFunc called' twice

Using off

var player = videojs('some-player-id');
var Component = videojs.getComponent('Component');
var myComponent = new Component(player);
var myFunc = function() {
  var myComponent = this;
  console.log('myFunc called');
};
myComponent.on('eventType', myFunc);
myComponent.trigger('eventType');
// logs 'myFunc called'

myComponent.off('eventType', myFunc);
myComponent.trigger('eventType');
// does nothing

If myFunc gets excluded, all listeners for the event type will get removed. If eventType gets excluded, all listeners will get removed from the component. You can use off to remove listeners that get added to other elements or components using:

myComponent.on(otherComponent...

In this case both the event type and listener function are REQUIRED.

var otherComponent = new Component(player);

// myComponent/myFunc is from the above example
myComponent.on(otherComponent.el(), 'eventName', myFunc);
myComponent.on(otherComponent, 'eventName', myFunc);

otherComponent.trigger('eventName');
// logs 'myFunc called' twice
myComponent.off(otherComponent.el(), 'eventName', myFunc);
myComponent.off(otherComponent, 'eventName', myFunc);
otherComponent.trigger('eventName');
// does nothing

Using one

var player = videojs('some-player-id');
var Component = videojs.getComponent('Component');
var myComponent = new Component(player);
var myFunc = function() {
  var myComponent = this;
  console.log('myFunc called');
};
myComponent.one('eventName', myFunc);
myComponent.trigger('eventName');
// logs 'myFunc called'

myComponent.trigger('eventName');
// does nothing

You can also add a listener to another element or component that will get triggered only once.

var otherComponent = new Component(player);

// myComponent/myFunc is from the above example
myComponent.one(otherComponent.el(), 'eventName', myFunc);
myComponent.one(otherComponent, 'eventName', myFunc);

otherComponent.trigger('eventName');
// logs 'myFunc called' twice

otherComponent.trigger('eventName');
// does nothing

Using trigger

var player = videojs('some-player-id');
var Component = videojs.getComponent('Component');
var myComponent = new Component(player);
var myFunc = function(data) {
  var myComponent = this;
  console.log('myFunc called');
  console.log(data);
};
myComponent.one('eventName', myFunc);
myComponent.trigger('eventName');
// logs 'myFunc called' and 'undefined'

myComponent.trigger({'type':'eventName'});
// logs 'myFunc called' and 'undefined'

myComponent.trigger('eventName', {data: 'some data'});
// logs 'myFunc called' and "{data: 'some data'}"

myComponent.trigger({'type':'eventName'}, {data: 'some data'});
// logs 'myFunc called' and "{data: 'some data'}"

Default Component Tree

The default component structure of the Video.js player looks something like this:

Player
├── MediaLoader (has no DOM element)
├── PosterImage
├── TextTrackDisplay
├── LoadingSpinner
├── BigPlayButton
├── LiveTracker (has no DOM element)
├─┬ ControlBar
│ ├── PlayToggle
│ ├── VolumePanel
│ ├── CurrentTimeDisplay (hidden by default)
│ ├── TimeDivider (hidden by default)
│ ├── DurationDisplay (hidden by default)
│ ├─┬ ProgressControl (hidden during live playback, except when liveui: true)
│ │ └─┬ SeekBar
│ │   ├── LoadProgressBar
│ │   ├── MouseTimeDisplay
│ │   └── PlayProgressBar
│ ├── LiveDisplay (hidden during VOD playback)
│ ├── SeekToLive (hidden during VOD playback)
│ ├── RemainingTimeDisplay
│ ├── CustomControlSpacer (has no UI)
│ ├── PlaybackRateMenuButton (hidden, unless playback tech supports rate changes)
│ ├── ChaptersButton (hidden, unless there are relevant tracks)
│ ├── DescriptionsButton (hidden, unless there are relevant tracks)
│ ├── SubsCapsButton (hidden, unless there are relevant tracks)
│ ├── AudioTrackButton (hidden, unless there are relevant tracks)
│ ├── PictureInPictureToggle
│ └── FullscreenToggle
├── ErrorDisplay (hidden, until there is an error)
├── TextTrackSettings
└── ResizeManager (hidden)

Specific Component Details

Play Toggle

The PlayToggle has one option replay which can show or hide replay icon. This can be set by passing {replay: false} as the default behavior replay icon is shown after video end playback.

Example of how to hide a replay icon

let player = videojs('myplayer', {
  controlBar: {
    playToggle: {
      replay: false
    }
  }
});

Volume Panel

The VolumePanel includes the MuteToggle and the VolumeControl Components, which will be hidden if volume changes are not supported. There is one important option for the VolumePanel which can make your VolumeControl appear vertically over the MuteToggle. This can be set by passing VolumePanel {inline: false} as the default behavior is a horizontal VolumeControl with {inline: true}.

Example of a vertical VolumeControl

let player = videojs('myplayer', {
  controlBar: {
    volumePanel: {
      inline: false
    }
  }
});

Text Track Settings

The text track settings component is only available when using emulated text tracks.

Resize Manager

This new component is in charge of triggering a playerresize event when the player size changed. It uses the ResizeObserver if available or a polyfill was provided. It has no element when using the ResizeObserver. If a ResizeObserver is not available, it will fallback to an iframe element and listen to its resize event via a debounced handler.

A ResizeObserver polyfill can be passed in like so:

var player = videojs('myplayer', {
  resizeManager: {
    ResizeObserver: ResizeObserverPoylfill
  }
});

To force using the iframe fallback, pass in null as the ResizeObserver:

var player = videojs('myplayer', {
  resizeManager: {
    ResizeObserver: null
  }
});

The ResizeManager can also just be disabled like so:

var player = videojs('myplayer', {
  resizeManager: false
});
孕妇手麻是什么原因引起的 调兵遣将是什么生肖 鼠的五行属什么 5月12号是什么星座 神经系统由什么组成
什么时候买机票便宜 梦见狗咬别人是什么意思 四维彩超主要检查什么 什么是川崎病是什么病 可可和咖啡有什么区别
晚上肚子疼是什么原因 阿胶糕适合什么人吃 通风什么征兆 舌息心念什么 机智如你是什么意思
血糖高吃什么可以降下来 十点是什么时辰 去湿气吃什么食物好 梦见红棺材是什么征兆 心跳过缓吃什么药
艾司唑仑片是什么药hcv9jop6ns7r.cn 鼻后滴漏吃什么药hcv8jop7ns5r.cn 寻麻疹是什么原因引起的hcv9jop4ns0r.cn 法国铁塔叫什么名字hcv7jop5ns2r.cn 六味地黄丸什么时候吃hcv9jop6ns9r.cn
感染四项挂什么科hcv8jop5ns3r.cn 穿刺活检能查出肿瘤是什么性质吗hcv8jop0ns7r.cn 耳鸣是什么原因导致的travellingsim.com 为什么会做梦中梦hcv9jop4ns1r.cn 植物神经是什么hcv8jop9ns8r.cn
周末大小休是什么意思hcv8jop6ns7r.cn 手一直脱皮是什么原因hcv7jop5ns3r.cn 皮肤疖是什么病hcv9jop6ns2r.cn 蒙圈什么意思hcv9jop2ns1r.cn 胃溃疡a2期是什么意思hcv8jop1ns8r.cn
肝囊肿是什么原因造成的hcv9jop6ns1r.cn 透明的剑是什么剑hcv8jop5ns5r.cn 梦见出国了是什么意思hcv9jop5ns4r.cn 贴切是什么意思wmyky.com 惊弓之鸟什么意思hcv9jop2ns2r.cn
百度