mirror of
https://github.com/zhw2590582/ArtPlayer.git
synced 2026-10-29 19:41:25 -08:00
V5 (#509)
* update artplayer.d.ts * update variables.less * update artplayerPluginControl * build:all * update docs * update docs * update docs * Update layers.md * update index.js * update docs * update docs
This commit is contained in:
1 parent
c8c08137c4
commit
ee49a0435e
202 files changed
+5293
-3466
No files matched your search
@@ -1,222 +0,0 @@
|
||||
# Component
|
||||
|
||||
The component configuration mentioned here mainly refers to three common configurations: `layers`, `controls` and `contextmenu`:
|
||||
|
||||
| Property | Type | Describe |
|
||||
| --------- | ------------------- | -------------------------------------------------- |
|
||||
| `disable` | `Boolean` | Whether to disable components |
|
||||
| `name` | `String` | Component unique name, used to mark the class name |
|
||||
| `index` | `Number` | Component index, used to display the priority of |
|
||||
| `html` | `String`, `Element` | DOM element of component |
|
||||
| `style` | `Object` | Component Style Object |
|
||||
| `click` | `Function` | Component click event |
|
||||
| `mounted` | `Function` | Triggered after the component is mounted |
|
||||
| `tooltip` | `String` | Prompt text for component |
|
||||
|
||||
:::warning Tip
|
||||
|
||||
- The current component can only be added, not destroyed
|
||||
- Use the 'name' option to quickly obtain the 'DOM' element of a component
|
||||
- The order in which components appear can be controlled through the 'index' option
|
||||
|
||||
:::
|
||||
|
||||
## `layers`
|
||||
|
||||
Add a layer during instantiation, such as `logo` or `advertisement`
|
||||
|
||||
<div className="run-code">▶ Run Code</div>
|
||||
|
||||
```js{5-22}
|
||||
var img = '/assets/sample/layer.png';
|
||||
var art = new Artplayer({
|
||||
container: '.artplayer-app',
|
||||
url: '/assets/sample/video.mp4',
|
||||
layers: [
|
||||
{
|
||||
name: 'potser',
|
||||
html: `<img style="width: 100px" src="${img}">`,
|
||||
tooltip: 'Potser Tip',
|
||||
style: {
|
||||
position: 'absolute',
|
||||
top: '50px',
|
||||
right: '50px',
|
||||
},
|
||||
click: function (...args) {
|
||||
console.info('click', args);
|
||||
},
|
||||
mounted: function (...args) {
|
||||
console.info('mounted', args);
|
||||
},
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
console.info(art.layers.potser);
|
||||
```
|
||||
|
||||
You can also add a layer after instantiation
|
||||
|
||||
<div className="run-code">▶ Run Code</div>
|
||||
|
||||
```js{7-22}
|
||||
var img = '/assets/sample/layer.png';
|
||||
var art = new Artplayer({
|
||||
container: '.artplayer-app',
|
||||
url: '/assets/sample/video.mp4',
|
||||
});
|
||||
|
||||
art.layers.add({
|
||||
name: 'potser',
|
||||
html: `<img style="width: 100px" src="${img}">`,
|
||||
tooltip: 'Potser Tip',
|
||||
style: {
|
||||
position: 'absolute',
|
||||
top: '50px',
|
||||
right: '50px',
|
||||
},
|
||||
click: function (...args) {
|
||||
console.info('click', args);
|
||||
},
|
||||
mounted: function (...args) {
|
||||
console.info('mounted', args);
|
||||
},
|
||||
});
|
||||
|
||||
console.info(art.layers.potser);
|
||||
```
|
||||
|
||||
## `controls`
|
||||
|
||||
Add a control during instantiation
|
||||
|
||||
:::warning There are three additional options for controls
|
||||
|
||||
- `position`: `left` and `right` positions of control controller
|
||||
- `selector`: Object array of selection list
|
||||
- `onSelect`: Function triggered when an element of the selection list is clicked
|
||||
|
||||
:::
|
||||
|
||||
<div className="run-code">▶ Run Code</div>
|
||||
|
||||
```js
|
||||
var art = new Artplayer({
|
||||
container: '.artplayer-app',
|
||||
url: '/assets/sample/video.mp4',
|
||||
controls: [
|
||||
{
|
||||
name: 'your-button',
|
||||
index: 10,
|
||||
position: 'left',
|
||||
html: 'Your Button',
|
||||
tooltip: 'Your Button',
|
||||
style: {
|
||||
color: 'red',
|
||||
},
|
||||
click: function (...args) {
|
||||
console.info('click', args);
|
||||
},
|
||||
mounted: function (...args) {
|
||||
console.info('mounted', args);
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'subtitle',
|
||||
position: 'right',
|
||||
html: 'Subtitle',
|
||||
selector: [
|
||||
{
|
||||
default: true,
|
||||
html: '<span style="color:red">subtitle 01</span>',
|
||||
},
|
||||
{
|
||||
html: '<span style="color:yellow">subtitle 02</span>',
|
||||
},
|
||||
],
|
||||
onSelect: function (item, $dom) {
|
||||
console.info(item, $dom);
|
||||
return 'Your ' + item.html;
|
||||
},
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
console.info(art.controls['your-button']);
|
||||
console.info(art.controls.subtitle);
|
||||
```
|
||||
|
||||
You can also add a control after instantiation
|
||||
|
||||
```js{6-22}
|
||||
var art = new Artplayer({
|
||||
container: '.artplayer-app',
|
||||
url: '/assets/sample/video.mp4',
|
||||
});
|
||||
|
||||
art.controls.add({
|
||||
name: 'button1',
|
||||
index: 10,
|
||||
position: 'left',
|
||||
html: 'Your Button',
|
||||
tooltip: 'Your Button',
|
||||
style: {
|
||||
color: 'red',
|
||||
},
|
||||
click: function (...args) {
|
||||
console.info('click', args);
|
||||
},
|
||||
mounted: function (...args) {
|
||||
console.info('mounted', args);
|
||||
},
|
||||
});
|
||||
|
||||
console.info(art.controls.button1);
|
||||
```
|
||||
|
||||
## `contextmenu`
|
||||
|
||||
Add a contextmenu during instantiation
|
||||
|
||||
<div className="run-code">▶ Run Code</div>
|
||||
|
||||
```js{4-13}
|
||||
var art = new Artplayer({
|
||||
container: '.artplayer-app',
|
||||
url: '/assets/sample/video.mp4',
|
||||
contextmenu: [
|
||||
{
|
||||
name: 'your-menu',
|
||||
html: 'Your Menu',
|
||||
click: function (...args) {
|
||||
console.info(args);
|
||||
art.contextmenu.show = false;
|
||||
},
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
console.info(art.contextmenu['your-menu']);
|
||||
```
|
||||
|
||||
You can also add a contextmenu after instantiation
|
||||
|
||||
<div className="run-code">▶ Run Code</div>
|
||||
|
||||
```js{6-13}
|
||||
var art = new Artplayer({
|
||||
container: '.artplayer-app',
|
||||
url: '/assets/sample/video.mp4',
|
||||
});
|
||||
|
||||
art.contextmenu.add({
|
||||
name: 'your-menu',
|
||||
html: 'Your Menu',
|
||||
click: function (...args) {
|
||||
console.info(args);
|
||||
art.contextmenu.show = false;
|
||||
},
|
||||
});
|
||||
|
||||
console.info(art.contextmenu['your-menu']);
|
||||
```
|
||||
@@ -630,7 +630,7 @@ var art = new Artplayer({
|
||||
|
||||
:::warning Please refer to the following address for `Component`:
|
||||
|
||||
[/start/component.html](/start/component.html)
|
||||
[/component/layers.html](/component/layers.html)
|
||||
|
||||
:::
|
||||
|
||||
@@ -683,7 +683,7 @@ var art = new Artplayer({
|
||||
|
||||
:::warning Please refer to the following address for `Setting`
|
||||
|
||||
[/start/setting.html](/start/setting.html)
|
||||
[/component/setting.html](/component/setting.html)
|
||||
|
||||
:::
|
||||
|
||||
@@ -714,7 +714,7 @@ var art = new Artplayer({
|
||||
|
||||
:::warning Please refer to the following address for `Component`:
|
||||
|
||||
[/start/component.html](/start/component.html)
|
||||
[/component/contextmenu.html](/component/contextmenu.html)
|
||||
|
||||
:::
|
||||
|
||||
@@ -749,7 +749,7 @@ var art = new Artplayer({
|
||||
|
||||
:::warning Please refer to the following address for `Setting`
|
||||
|
||||
[/start/setting.html](/start/setting.html)
|
||||
[/component/controls.html](/component/controls.html)
|
||||
|
||||
:::
|
||||
|
||||
@@ -928,13 +928,14 @@ var art = new Artplayer({
|
||||
|
||||
Set the subtitle of the video and support the subtitle format: `vtt`, `srt`, `ass`
|
||||
|
||||
| Property | Type | Describe |
|
||||
| ---------- | --------- | ------------------------------------------------ |
|
||||
| `url` | `String` | Subtitle url |
|
||||
| `type` | `String` | Subtitle type: `vtt`, `srt`, `ass` |
|
||||
| `style` | `Object` | Subtitle style |
|
||||
| `encoding` | `String` | Subtitle code, Default: `utf-8` |
|
||||
| `escape` | `Boolean` | Whether to escape the `html` tag,Default: `true` |
|
||||
| Property | Type | Describe |
|
||||
| ----------- | ---------- | ------------------------------------------------ |
|
||||
| `url` | `String` | Subtitle url |
|
||||
| `type` | `String` | Subtitle type: `vtt`, `srt`, `ass` |
|
||||
| `style` | `Object` | Subtitle style |
|
||||
| `encoding` | `String` | Subtitle code, Default: `utf-8` |
|
||||
| `escape` | `Boolean` | Whether to escape the `html` tag,Default: `true` |
|
||||
| `onVttLoad` | `Function` | Functions for modifying `vtt` text |
|
||||
|
||||
<div className="run-code">▶ Run Code</div>
|
||||
|
||||
@@ -1212,3 +1213,28 @@ var art = new Artplayer({
|
||||
airplay: true,
|
||||
});
|
||||
```
|
||||
|
||||
## `cssVar`
|
||||
|
||||
- Type: `Object`
|
||||
- Default: `{}`
|
||||
|
||||
Used to change built-in CSS variables
|
||||
|
||||
<div className="run-code">▶ Run Code</div>
|
||||
|
||||
```js{4}
|
||||
var art = new Artplayer({
|
||||
container: '.artplayer-app',
|
||||
url: '/assets/sample/video.mp4',
|
||||
cssVar: {
|
||||
//
|
||||
},
|
||||
});
|
||||
```
|
||||
|
||||
:::warning cssVar definitions
|
||||
|
||||
[artplayer/types/cssVar.d.d.ts](https://github.com/zhw2590582/ArtPlayer/blob/master/packages/artplayer/types/cssVar.d.ts)
|
||||
|
||||
:::
|
||||
@@ -1,213 +0,0 @@
|
||||
# 设置面板
|
||||
|
||||
You need to open the settings panel first. The player has four settings by default: `flip`, `playbackRate`, `aspectRatio`, `subtitleOffset`
|
||||
|
||||
<div className="run-code">▶ Run Code</div>
|
||||
|
||||
```js{4}
|
||||
var art = new Artplayer({
|
||||
container: '.artplayer-app',
|
||||
url: '/assets/sample/video.mp4',
|
||||
setting: true,
|
||||
flip: true,
|
||||
playbackRate: true,
|
||||
aspectRatio: true,
|
||||
subtitleOffset: true,
|
||||
});
|
||||
```
|
||||
|
||||
## Selection list
|
||||
|
||||
| Property | Type | Describe |
|
||||
| ---------- | ------------------- | ------------------- |
|
||||
| `html` | `String`, `Element` | DOM of element |
|
||||
| `icon` | `String`, `Element` | Icon of element |
|
||||
| `selector` | `Array` | Element list |
|
||||
| `onSelect` | `Function` | Element click event |
|
||||
| `width` | `Number` | List width |
|
||||
| `tooltip` | `String` | Prompt text |
|
||||
|
||||
<div className="run-code">▶ Run Code</div>
|
||||
|
||||
```js
|
||||
var art = new Artplayer({
|
||||
container: '.artplayer-app',
|
||||
url: '/assets/sample/video.mp4',
|
||||
setting: true,
|
||||
settings: [
|
||||
{
|
||||
html: 'Subtitle',
|
||||
width: 250,
|
||||
tooltip: 'Subtitle 01',
|
||||
selector: [
|
||||
{
|
||||
default: true,
|
||||
html: '<span style="color:red">Subtitle 01</span>',
|
||||
url: '/assets/sample/subtitle.srt?id=1',
|
||||
},
|
||||
{
|
||||
html: '<span style="color:yellow">Subtitle 02</span>',
|
||||
url: '/assets/sample/subtitle.srt?id=2',
|
||||
},
|
||||
],
|
||||
onSelect: function (item, $dom, event) {
|
||||
console.info(item, $dom, event);
|
||||
art.subtitle.url = item.url;
|
||||
return item.html;
|
||||
},
|
||||
},
|
||||
{
|
||||
html: 'Quality',
|
||||
width: 150,
|
||||
tooltip: '1080P',
|
||||
selector: [
|
||||
{
|
||||
default: true,
|
||||
html: '1080P',
|
||||
url: '/assets/sample/video.mp4?id=1080',
|
||||
},
|
||||
{
|
||||
html: '720P',
|
||||
url: '/assets/sample/video.mp4?id=720',
|
||||
},
|
||||
{
|
||||
html: '360P',
|
||||
url: '/assets/sample/video.mp4?id=360',
|
||||
},
|
||||
],
|
||||
onSelect: function (item, $dom, event) {
|
||||
console.info(item, $dom, event);
|
||||
art.switchQuality(item.url, item.html);
|
||||
return item.html;
|
||||
},
|
||||
},
|
||||
],
|
||||
});
|
||||
```
|
||||
|
||||
## List nesting
|
||||
|
||||
<div className="run-code">▶ Run Code</div>
|
||||
|
||||
```js
|
||||
var art = new Artplayer({
|
||||
container: '.artplayer-app',
|
||||
url: '/assets/sample/video.mp4',
|
||||
setting: true,
|
||||
settings: [
|
||||
{
|
||||
html: 'Multi-level',
|
||||
selector: [
|
||||
{
|
||||
html: 'Setting 01',
|
||||
width: 150,
|
||||
selector: [
|
||||
{
|
||||
html: 'Setting 01 - 01',
|
||||
},
|
||||
{
|
||||
html: 'Setting 01 - 02',
|
||||
},
|
||||
],
|
||||
onSelect: function (item, $dom, event) {
|
||||
console.info(item, $dom, event);
|
||||
return item.html;
|
||||
},
|
||||
},
|
||||
{
|
||||
html: 'Setting 02',
|
||||
width: 150,
|
||||
selector: [
|
||||
{
|
||||
html: 'Setting 02 - 01',
|
||||
},
|
||||
{
|
||||
html: 'Setting 02 - 02',
|
||||
},
|
||||
],
|
||||
onSelect: function (item, $dom, event) {
|
||||
console.info(item, $dom, event);
|
||||
return item.html;
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
});
|
||||
```
|
||||
|
||||
## Toggle button
|
||||
|
||||
| Property | Type | Describe |
|
||||
| ---------- | ------------------- | ---------------------- |
|
||||
| `html` | `String`, `Element` | DOM of element |
|
||||
| `icon` | `String`, `Element` | Icon of element |
|
||||
| `switch` | `Boolean` | Button default state |
|
||||
| `onSwitch` | `Function` | Button switching event |
|
||||
| `tooltip` | `String` | Prompt text |
|
||||
|
||||
<div className="run-code">▶ Run Code</div>
|
||||
|
||||
```js
|
||||
var art = new Artplayer({
|
||||
container: '.artplayer-app',
|
||||
url: '/assets/sample/video.mp4',
|
||||
setting: true,
|
||||
settings: [
|
||||
{
|
||||
html: 'PIP Mode',
|
||||
tooltip: 'Close',
|
||||
icon: '<img width="22" heigth="22" src="/assets/img/state.svg">',
|
||||
switch: false,
|
||||
onSwitch: function (item, $dom, event) {
|
||||
console.info(item, $dom, event);
|
||||
const nextState = !item.switch;
|
||||
art.pip = nextState;
|
||||
item.tooltip = nextState ? 'Open' : 'Close';
|
||||
return nextState;
|
||||
},
|
||||
},
|
||||
],
|
||||
});
|
||||
```
|
||||
|
||||
## Range Slider
|
||||
|
||||
| Property | Type | Describe |
|
||||
| ---------- | ------------------- | ------------------------------ |
|
||||
| `html` | `String`, `Element` | DOM of element |
|
||||
| `icon` | `String`, `Element` | Icon of element |
|
||||
| `range` | `Array` | Default state array |
|
||||
| `onRange` | `Function` | Event triggered on completion |
|
||||
| `onChange` | `Function` | Events triggered when changing |
|
||||
| `tooltip` | `String` | Prompt text |
|
||||
|
||||
```js
|
||||
const range = [5, 1, 10, 1];
|
||||
const value = range[0];
|
||||
const min = range[1];
|
||||
const max = range[2];
|
||||
const step = range[3];
|
||||
```
|
||||
|
||||
<div className="run-code">▶ Run Code</div>
|
||||
|
||||
```js
|
||||
var art = new Artplayer({
|
||||
container: '.artplayer-app',
|
||||
url: '/assets/sample/video.mp4',
|
||||
setting: true,
|
||||
settings: [
|
||||
{
|
||||
html: 'Slider',
|
||||
tooltip: '5x',
|
||||
icon: '<img width="22" heigth="22" src="/assets/img/state.svg">',
|
||||
range: [5, 1, 10, 1],
|
||||
onChange: function (item, $dom, event) {
|
||||
console.info(item, $dom, event);
|
||||
return item.range + 'x';
|
||||
},
|
||||
},
|
||||
],
|
||||
});
|
||||
```
|
||||
Reference in new issue
Block a user