0.0.9 • Published 3 years ago

alife-iotx-oler-player v0.0.9

Weekly downloads
1
License
ISC
Repository
-
Last release
3 years ago

执法宝录像播放控件

示例

const player = new window.OlerPlayer('player', ['http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4']);
player.loadSubtitle('test.srt');
player.setHighlightText('翻译');
player.setChapters([
    {
        "sceneId": 1,
        "sceneName": "关键场景1",
        "startTime": 9.253,
        "finishTime": 33.253,
    },
    {
        "sceneId": 2,
        "sceneName": "关键场景2",
        "startTime": 33.253,
        "finishTime": 43.253,
    },
]);

提供的方法

初始化

new window.OlerPlayer(elementId, videoSrc, subtitle, chapters)

elementId: 挂载的 DOM 节点的 id videoSrc: 视频的 url subtitle: 字幕文件的 url chapters: 视频分段数据,格式如上方示例

new window.OlerPlayer(options)

options: 初始化参数,即上方4个参数包装成一个对象

加载字幕

loadSubtitle(subtitle)

subtitle: 字幕文件的 url

给每一条字幕添加样式

addStyleToEverySubtitle(style)

style: 字幕样式对象,例如:{ marginBottom: 20 }

设置高亮文字

setHighlightText(text)

text: 需要高亮的文字

设置分段数据

setChapters(chapters)

chapters: 视频分段数据,格式如上方示例

销毁

destroy()

把控件从挂载节点上销毁