首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >为VideoJS 5编写插件

为VideoJS 5编写插件
EN

Stack Overflow用户
提问于 2015-06-17 15:35:09
回答 1查看 1.1K关注 0票数 0

当我尝试使用最新版本的视频is 5时,下面的代码不再工作了。我正在尝试写一个视频is插件,但视频is 5使用ecmascript 6,这对我来说是新的。任何帮助都是非常感谢的。

代码语言:javascript
复制
   videojs.SharingButton = videojs.Button.extend({
    /** @constructor */
    init: function(player, options){
        videojs.Button.call(this, player, options);
        this.player = player;
    }
});

videojs.SharingButton.prototype.createEl = function(tagName,options) {
    return videojs.Component.prototype.createEl(tagName,{
        className: this.buildCSSClass(),
        innerHTML: '',
        role: 'button',
        'aria-live': 'polite', // let the screen reader user know that the text of the button may change
        tabIndex: 0
    });
}

videojs.SharingButton.prototype.buttonText = 'Share Video';

videojs.SharingButton.prototype.options_ = {};

videojs.SharingButton.prototype.buildCSSClass = function(){
    return 'vjs-sharing-control ';
};
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-12-08 23:44:30

嗨,我也有同样的问题,替换这个代码

videojs.SharingButton = videojs.Button.extend({

通过

代码语言:javascript
复制
var SharingButton = videojs.getComponent('Button');
videojs.SharingButton = videojs.extend(SharingButton , {...});
videojs.registerComponent('SharingButton', SharingButton);

var myButton = myPlayer.addChild('SharingButton');

如果要添加一个不是player元素的直接子元素的组件,则必须爬上子元素并添加该组件。比如:

代码语言:javascript
复制
parentComponent = myPlayer.getChild('component1').getChild('component2')...
parentComponent.addChild('SharingButton')

请注意,播放机组件必须启动小写,如controlBar

在这个链接中找到组件树。

在构建5.0版本(请参阅此链接)时,进行了许多更改,不幸的是,大多数视频as插件没有更新它们的代码!主题之一是社会按钮共享

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/30896122

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档