Security News
Fluent Assertions Faces Backlash After Abandoning Open Source Licensing
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
xgplayer-subtitles
Advanced tools
外挂字幕组件,目前支持vtt格式的解析
Install
$ npm install xgplayer-subtitles
Usage
Step 1:
<div id="vs"></div>
Step 2:
import Player from 'xgplayer';
const player = new Player({
id: 'vs',
url: ''
})
const options = {
player: player, // 可选, 如果初始化的时候已经有播放器实例
subTitles: [{ //必选 字幕信息
label: '中文',
language : '', //必选
id: 'cn', //必选
isDefault: false, //必选 是否是默认字幕
url: './subtitle/cn.vtt' //必选 字幕链接地址
}, {
label: '英文',
url: './subtitle/en.vtt',
id: 'en',
isDefault: true,
language: 'en'
}],
defaultOpen: false, // 是否默认开启字幕
mode: 'bg', //可选 字幕显示模式,支持bg(背景)和 stroke(字体边框填充),默认stroke
line: 'double' //可选 字幕最大显示行数 默认单行,single, 支持single/double/three,
}
const subTitle = new window.XgSubtitle(options)
// 如果在初始化的时候播放器还没有播放器实例,也可以使用以下挂载播放器
subTitle.attachPlayer(player)
挂载播放器实例
卸载播放器实例
销毁组件
切换字幕
subtitle.switch({id: 'cn'}).then(() => {
console.log('切换成功')
}).catch(() => {
console.log('切换失败')
})
切换信息返回说明
{
code: 0, // 切换成功
msg: 'SUCCESS'
},{
code: 1, // 下载错误
msg: 'LOAD_ERROR'
}, {
code: 2, // 解析错误
msg: 'PARSER_ERROR'
}, {
code: 3, // 格式不支持
msg: 'FORMAT_NOT_SUPPORTED'
},
{
code: 4, // id或者语言不存在
msg: 'ID_OR_LANGUAGE_NOT_EXIST'
}, {
code: 5, // 参数错误
msg: 'PARAMETERS_ERROR'
}, {
code: 6, // 操作中断
msg: 'ABORT'
}, {
code: 7, // 未知错误
msg: 'UNKNOWN'
}
关闭当前字幕
FAQs
外挂字幕组件,目前支持vtt格式的解析
The npm package xgplayer-subtitles receives a total of 3,751 weekly downloads. As such, xgplayer-subtitles popularity was classified as popular.
We found that xgplayer-subtitles demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.