mirror of
https://github.com/zhw2590582/ArtPlayer.git
synced 2026-10-09 20:26:16 -08:00
优化字幕传参
This commit is contained in:
1 parent
92686dfcb6
commit
deaa4fa13d
7 files changed
+56
-47
No files matched your search
@@ -667,7 +667,7 @@ Custom subtitle
|
||||
| ----------- | --------- | ---------------------------------------- |
|
||||
| `url` | `String` | Subtitle url, support vtt and srt format |
|
||||
| `style` | `Object` | Subtitle style |
|
||||
| `encoding` | `String` | Subtitle encoding |
|
||||
| `encoding` | `String` | Subtitle encoding, default is `utf-8` |
|
||||
| `bilingual` | `Boolean` | Whether bilingual subtitles |
|
||||
|
||||
[Run Code](/Configuration.subtitle)
|
||||
@@ -678,6 +678,8 @@ var art = new Artplayer({
|
||||
url: '/assets/sample/video.mp4',
|
||||
subtitle: {
|
||||
url: '/assets/sample/subtitle.srt',
|
||||
encoding: 'utf-8',
|
||||
bilingual: true,
|
||||
style: {
|
||||
color: '#03A9F4',
|
||||
'font-size': '30px',
|
||||
|
||||
+25
-10
@@ -318,14 +318,21 @@ art.contextmenu.add({
|
||||
|
||||
- Type: `Object`
|
||||
|
||||
| propertie | type | Description |
|
||||
| ---------- | --------------- | --------------------- |
|
||||
| `init` | `Function` | Init subtitle |
|
||||
| `show` | `setter` | Show or hide |
|
||||
| `switch` | `Function` | Switch subtitle |
|
||||
| `url` | `getter` | get subtitle url |
|
||||
| `encoding` | `getter/setter` | Get and set encoding |
|
||||
| `style` | `Function` | Modify subtitle style |
|
||||
| propertie | type | Description |
|
||||
| --------- | ---------- | --------------------- |
|
||||
| `init` | `Function` | Init subtitle |
|
||||
| `show` | `setter` | Show or hide |
|
||||
| `switch` | `Function` | Switch subtitle |
|
||||
| `url` | `getter` | get subtitle url |
|
||||
| `style` | `Function` | Modify subtitle style |
|
||||
|
||||
Both `init` and `switch` accept subtitle url as the first parameter, and the second parameter as optional:
|
||||
|
||||
| propertie | type | Description |
|
||||
| ---------- | -------- | ----------------- |
|
||||
| `name` | `String` | Subtitle name |
|
||||
| `ext` | `String` | Subtitle format |
|
||||
| `encoding` | `String` | Subtitle encoding |
|
||||
|
||||
[Run Code](/Properties.subtitle)
|
||||
|
||||
@@ -344,7 +351,11 @@ var art = new Artplayer({
|
||||
html: 'subtitle 01',
|
||||
click: function () {
|
||||
art.subtitle.style('color', 'green');
|
||||
art.subtitle.switch('/assets/sample/subtitle.srt', 'srt subtitle name');
|
||||
art.subtitle.switch('/assets/sample/subtitle.srt', {
|
||||
name: 'srt subtitle name',
|
||||
ext: 'srt',
|
||||
encoding: 'utf-8',
|
||||
});
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -353,7 +364,11 @@ var art = new Artplayer({
|
||||
html: 'subtitle 02',
|
||||
click: function () {
|
||||
art.subtitle.style('color', 'red');
|
||||
art.subtitle.switch('/assets/sample/subtitle.vtt', 'vtt subtitle name');
|
||||
art.subtitle.switch('/assets/sample/subtitle.vtt', {
|
||||
name: 'vtt subtitle name',
|
||||
ext: 'vtt',
|
||||
encoding: 'utf-8',
|
||||
});
|
||||
},
|
||||
},
|
||||
],
|
||||
|
||||
@@ -23,7 +23,9 @@ var art = new Artplayer({
|
||||
},
|
||||
],
|
||||
onSelect: function (item) {
|
||||
art.subtitle.switch(item.url, item.name);
|
||||
art.subtitle.switch(item.url, {
|
||||
name: item.name
|
||||
});
|
||||
},
|
||||
},
|
||||
],
|
||||
|
||||
Reference in new issue
Block a user