npm install --save viu-player
To include viu-player on your website or web application, use any of the following methods.
This is the simplest case. Get the script in whatever way you prefer and include the plugin after you include video.js, so that the videojs
global is available.
<script src="//path/to/video.min.js"></script>
<script src="//path/to/viu-player.min.js"></script>
<script>
var player = videojs("my-video");
player.ViuPlayer();
</script>
When using with Browserify, install viu-player via npm and require
the plugin as you would any other module.
var videojs = require("video.js");
// The actual plugin function is exported by this module, but it is also
// attached to the `Player.prototype`; so, there is no need to assign it
// to a variable.
require("viu-player");
var player = videojs("my-video");
player.ViuPlayer();
When using with RequireJS (or another AMD library), get the script in whatever way you prefer and require
the plugin as you normally would:
require(["video.js", "viu-player"], function(videojs) {
var player = videojs("my-video");
player.ViuPlayer();
});
player.on("subtitleChange", function(event,langId) {
//data :string etc: 1,2,3 langId
});
player.on("subtitleClick", function(event,langData) {
//data :string langData
});
player.ViuPlayer().loadNewLangListOptions(langData);
//主动方法
player.ViuPlayer()toggleNextChip();
player.on("nextChip", function() {
//
});
//隐藏方法
player.ViuPlayer().hideTopSubtitle();
// 打开方法
player.ViuPlayer().showTopSubtitle();
player.on("toggleTopSubtitle", function(event, switcher) {
console.log("收到双字幕开关", switcher);
})
player.ViuPlayer().checkVideoProcessed();
player.ViuPlayer().toggleInfo();
languages: [
{
id: 'CN',
name: '简体中文',
isDefault: 0
},
{
id: 'EN',
name: 'ENGLISH',
isDefault: 1
},
{
id: 'JP',
name: '日文',
isDefault: 0
}
],
.lang-active{
// 语言选择状态
}
.status-active{
// 六图标状态
}
examplePlayer.on("loadTimeout", function() {
console.log("loading超60秒");
});
options.videoBufferTimeout // 定义网络慢超时时间
info: {
chipName: '',
episode: '',
chipCaptions: '',
chipDesc: '',
chipTotal: 0,
isMovie: 0,
chipActiveTotal: 0,
userLevel: '',
pUrl: '',
showPremium: true,
}
advance: {
resolutionList: ['s1080p', 's720p', 's480p', 's240p'],
defaultResolution: 's720p',
cdnList: ['url', 'url2', 'url3'],
defaultCdn: 'url2'
}
examplePlayer.on("viuAdvance", function(event,data) {
console.log("viuAdvance",data);
// ex: selectId: s1080p
});
examplePlayer.on("weakNetwork", function(event,data) {
// 网络提示
//
});
MIT. Copyright (c) gemer cheung <gemercheung@gmail.com>