mirror of
https://github.com/zhw2590582/ArtPlayer.git
synced 2026-10-15 00:56:16 -08:00
feat: 增加动态设置字幕偏移功能,更新相关文档
This commit is contained in:
1 parent
36fb27d7a1
commit
211e9d22a2
6 files changed
+49
-4
No files matched your search
@@ -964,4 +964,27 @@ art.on('ready', () => {
|
||||
column: 10,
|
||||
};
|
||||
});
|
||||
```
|
||||
|
||||
## `subtitleOffset`
|
||||
|
||||
- Type: `Setter/Getter`
|
||||
- Parameter: `Number`
|
||||
|
||||
动态设置字幕偏移
|
||||
|
||||
<div className="run-code">▶ Run Code</div>
|
||||
|
||||
```js
|
||||
var art = new Artplayer({
|
||||
container: '.artplayer-app',
|
||||
url: '/assets/sample/video.mp4',
|
||||
subtitle: {
|
||||
url: '/assets/sample/subtitle.srt',
|
||||
},
|
||||
});
|
||||
|
||||
art.on('ready', () => {
|
||||
art.subtitleOffset = 1;
|
||||
});
|
||||
```
|
||||
@@ -948,4 +948,27 @@ art.on('ready', () => {
|
||||
column: 10,
|
||||
};
|
||||
});
|
||||
```
|
||||
|
||||
## `subtitleOffset`
|
||||
|
||||
- Type: `Setter/Getter`
|
||||
- Parameter: `Number`
|
||||
|
||||
Dynamically set subtitle offset
|
||||
|
||||
<div className="run-code">▶ Run Code</div>
|
||||
|
||||
```js
|
||||
var art = new Artplayer({
|
||||
container: '.artplayer-app',
|
||||
url: '/assets/sample/video.mp4',
|
||||
subtitle: {
|
||||
url: '/assets/sample/subtitle.srt',
|
||||
},
|
||||
});
|
||||
|
||||
art.on('ready', () => {
|
||||
art.subtitleOffset = 1;
|
||||
});
|
||||
```
|
||||
@@ -23,7 +23,6 @@ var art = new Artplayer({
|
||||
| Property | Type | Description |
|
||||
| ---------- | ------------------- | ------------ |
|
||||
| `html` | `String`, `Element` | Element's DOM |
|
||||
|
||||
| `icon` | `String`, `Element` | 元素的图标 |
|
||||
| `selector` | `Array` | 元素列表 |
|
||||
| `onSelect` | `Function` | 元素点击事件 |
|
||||
|
||||
@@ -10,7 +10,7 @@ export default function subtitleOffsetMix(art) {
|
||||
set(value) {
|
||||
const { cues } = art.subtitle;
|
||||
if (!template.$track || cues.length === 0) return;
|
||||
const offset = clamp(value, -5, 5);
|
||||
const offset = clamp(value, -10, 10);
|
||||
template.$track.offset = offset;
|
||||
for (let index = 0; index < cues.length; index++) {
|
||||
const cue = cues[index];
|
||||
|
||||
Reference in new issue
Block a user