mirror of
https://github.com/zhw2590582/ArtPlayer.git
synced 2026-10-18 19:01:20 -08:00
update
This commit is contained in:
1 parent
5e9057f060
commit
4d66a8538d
18 files changed
+137
-118
No files matched your search
@@ -550,7 +550,7 @@ var art = new Artplayer({
|
||||
- Type: `Array`
|
||||
- Default: `[]`
|
||||
|
||||
Initialize custom setting panel, please visit [How to add setting](/document/Questions/)
|
||||
Initialize custom setting panel, please visit [How to add setting panel](/document/en/Questions/How%20to%20add%20setting%20panel)
|
||||
|
||||
<div className="run-code">▶ Run Code</div>
|
||||
|
||||
@@ -562,7 +562,24 @@ var art = new Artplayer({
|
||||
settings: [
|
||||
{
|
||||
html: 'Custom setting 01',
|
||||
items: [
|
||||
children: [
|
||||
{
|
||||
html: 'Submenu 01',
|
||||
click: function() {
|
||||
console.log('You click on the submenu 01');
|
||||
}
|
||||
},
|
||||
{
|
||||
html: 'Submenu 02',
|
||||
click: function() {
|
||||
console.log('You click on the submenu 02');
|
||||
}
|
||||
},
|
||||
]
|
||||
},
|
||||
{
|
||||
html: 'Custom setting 02',
|
||||
children: [
|
||||
{
|
||||
html: 'Submenu 01',
|
||||
click: function() {
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
---
|
||||
title: How to add setting panel
|
||||
sidebar_position: 6
|
||||
---
|
||||
@@ -1,4 +0,0 @@
|
||||
---
|
||||
title: How to add setting
|
||||
sidebar_position: 6
|
||||
---
|
||||
@@ -550,7 +550,7 @@ var art = new Artplayer({
|
||||
- 类型: `Array`
|
||||
- 默认: `[]`
|
||||
|
||||
初始化自定义的设置面板,更多信息请访问 [怎么添加设置面板](/document/zh-cn/Questions/)
|
||||
初始化自定义的设置面板,更多信息请访问 [怎么添加设置面板](/document/zh-cn/Questions/How%20to%20add%20setting%20panel)
|
||||
|
||||
<div className="run-code">▶ Run Code</div>
|
||||
|
||||
@@ -562,7 +562,24 @@ var art = new Artplayer({
|
||||
settings: [
|
||||
{
|
||||
html: '自定义设置01',
|
||||
items: [
|
||||
children: [
|
||||
{
|
||||
html: '子菜单01',
|
||||
click: function() {
|
||||
console.log('你点击了子菜单01');
|
||||
}
|
||||
},
|
||||
{
|
||||
html: '子菜单02',
|
||||
click: function() {
|
||||
console.log('你点击了子菜单01');
|
||||
}
|
||||
},
|
||||
]
|
||||
},
|
||||
{
|
||||
html: '自定义设置02',
|
||||
children: [
|
||||
{
|
||||
html: '子菜单01',
|
||||
click: function() {
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
---
|
||||
title: 怎么添加设置面板
|
||||
sidebar_position: 6
|
||||
---
|
||||
|
||||
设置面板类似于列表选择的集合,而且支持多层嵌套
|
||||
|
||||
### 切换字幕
|
||||
|
||||
<div className="run-code">▶ Run Code</div>
|
||||
|
||||
```js
|
||||
var art = new Artplayer({
|
||||
container: '.artplayer-app',
|
||||
url: '/assets/sample/video.mp4',
|
||||
setting: true,
|
||||
flip: true,
|
||||
playbackRate: true,
|
||||
aspectRatio: true,
|
||||
settings: [
|
||||
{
|
||||
html: 'Subtitle',
|
||||
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) {
|
||||
console.info(item, $dom);
|
||||
|
||||
art.subtitle.url = item.url;
|
||||
|
||||
return '你点击了 ' + item.html;
|
||||
},
|
||||
},
|
||||
],
|
||||
});
|
||||
```
|
||||
@@ -1,4 +0,0 @@
|
||||
---
|
||||
title: 怎么添加设置面板
|
||||
sidebar_position: 6
|
||||
---
|
||||
@@ -1,65 +0,0 @@
|
||||
var art = new Artplayer({
|
||||
container: '.artplayer-app',
|
||||
url: 'https://artplayer.org/assets/sample/video.mp4',
|
||||
muted: true,
|
||||
autoSize: true,
|
||||
autoplay: true,
|
||||
ads: [
|
||||
{
|
||||
url: '/assets/sample/test1.mp4'
|
||||
},
|
||||
{
|
||||
url: '/assets/sample/test2.webm'
|
||||
},
|
||||
],
|
||||
controls: [
|
||||
{
|
||||
position: 'right',
|
||||
html: '跳过广告',
|
||||
click: function () {
|
||||
art.ads.end();
|
||||
},
|
||||
},
|
||||
],
|
||||
layers: [
|
||||
{
|
||||
html: '跳过广告',
|
||||
style: {
|
||||
position: 'absolute',
|
||||
top: '20px',
|
||||
right: '20px',
|
||||
},
|
||||
click: function () {
|
||||
art.ads.end();
|
||||
},
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
// 当每个视频广告播放时触发
|
||||
art.on('ads:start', function(item) {
|
||||
console.info('广告开始播放: ' + item.url);
|
||||
});
|
||||
|
||||
// 当全部视频广告播放完成
|
||||
art.on('ads:end', function() {
|
||||
console.info('广告已经结束');
|
||||
});
|
||||
|
||||
// 当前广告的下标
|
||||
console.info(art.ads.index);
|
||||
|
||||
// 广告是否已经结束
|
||||
console.info(art.ads.isEnd);
|
||||
|
||||
// 广告是否正在播放
|
||||
console.info(art.ads.playing);
|
||||
|
||||
// 上一个广告的对象
|
||||
console.info(art.ads.prev);
|
||||
|
||||
// 当前广告的对象
|
||||
console.info(art.ads.current);
|
||||
|
||||
// 下一个广告的对象
|
||||
console.info(art.ads.next);
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "artplayer-plugin-danmuku",
|
||||
"version": "4.1.0",
|
||||
"version": "4.3.0",
|
||||
"expose": "artplayerPluginDanmuku",
|
||||
"description": "Danmuku plugin for ArtPlayer",
|
||||
"main": "dist/artplayer-plugin-danmuku.js",
|
||||
|
||||
@@ -5,11 +5,11 @@ export default function aspectRatio(art) {
|
||||
width: 150,
|
||||
html: i18n.get('Aspect Ratio'),
|
||||
icon: icons.aspectRatio,
|
||||
children: ['default', '4:3', '16:9'].map((item) => {
|
||||
selector: ['default', '4:3', '16:9'].map((item) => {
|
||||
return {
|
||||
html: item === 'default' ? i18n.get('Default') : item,
|
||||
current: item === 'default',
|
||||
click() {
|
||||
onSelect() {
|
||||
art.aspectRatio = item;
|
||||
},
|
||||
};
|
||||
|
||||
@@ -10,11 +10,11 @@ export default function playbackRate(art) {
|
||||
return {
|
||||
width: 150,
|
||||
html: i18n.get('Video Flip'),
|
||||
children: Object.keys(keys).map((key) => {
|
||||
selector: Object.keys(keys).map((key) => {
|
||||
return {
|
||||
html: i18n.get(keys[key]),
|
||||
current: key === 'normal',
|
||||
click() {
|
||||
onSelect() {
|
||||
art.flip = key;
|
||||
},
|
||||
};
|
||||
|
||||
@@ -8,13 +8,13 @@ import { append, addClass, setStyle, inverseClass, includeFromEvent } from '../u
|
||||
function makeRecursion(option) {
|
||||
for (let index = 0; index < option.length; index++) {
|
||||
const item = option[index];
|
||||
if (!item.back && item.children) {
|
||||
item.children.unshift({
|
||||
if (!item.back && item.selector) {
|
||||
item.selector.unshift({
|
||||
html: item.html,
|
||||
children: option,
|
||||
selector: option,
|
||||
back: true,
|
||||
});
|
||||
makeRecursion(item.children);
|
||||
makeRecursion(item.selector);
|
||||
}
|
||||
}
|
||||
return option;
|
||||
@@ -90,7 +90,7 @@ export default class Setting extends Component {
|
||||
} = this.art;
|
||||
|
||||
const $item = document.createElement('div');
|
||||
const hasChildren = item.children && item.children.length;
|
||||
const hasChildren = item.selector && item.selector.length;
|
||||
|
||||
const $left = append($item, `<div class="art-setting-item-left"></div>`);
|
||||
const $right = append($item, `<div class="art-setting-item-right"></div>`);
|
||||
@@ -116,12 +116,12 @@ export default class Setting extends Component {
|
||||
}
|
||||
|
||||
proxy($item, 'click', (event) => {
|
||||
if (typeof item.click === 'function') {
|
||||
item.click.call(this.art, this, event);
|
||||
if (typeof item.onSelect === 'function') {
|
||||
item.onSelect.call(this.art, this, event);
|
||||
}
|
||||
|
||||
if (hasChildren) {
|
||||
this.init(item.children);
|
||||
this.init(item.selector);
|
||||
setStyle(this.$parent, 'width', `${item.width || this.width}px`);
|
||||
} else {
|
||||
inverseClass($item, 'art-current');
|
||||
|
||||
@@ -5,11 +5,11 @@ export default function playbackRate(art) {
|
||||
width: 150,
|
||||
html: i18n.get('Play Speed'),
|
||||
icon: icons.playbackRate,
|
||||
children: [0.25, 0.5, 0.75, 1.0, 1.25, 1.5, 1.75, 2.0].map((item) => {
|
||||
selector: [0.25, 0.5, 0.75, 1.0, 1.25, 1.5, 1.75, 2.0].map((item) => {
|
||||
return {
|
||||
html: item === 1.0 ? i18n.get('Normal') : item,
|
||||
current: item === 1.0,
|
||||
click() {
|
||||
onSelect() {
|
||||
art.playbackRate = item;
|
||||
},
|
||||
};
|
||||
|
||||
@@ -5,11 +5,11 @@ export default function subtitleOffset(art) {
|
||||
width: 150,
|
||||
html: i18n.get('Subtitle Offset'),
|
||||
icon: icons.subtitle,
|
||||
children: [-5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5].map((item) => {
|
||||
selector: [-5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5].map((item) => {
|
||||
return {
|
||||
html: item === 0 ? i18n.get('Normal') : item,
|
||||
current: item === 0,
|
||||
click() {
|
||||
onSelect() {
|
||||
art.subtitleOffset = item;
|
||||
},
|
||||
};
|
||||
|
||||
+7
-2
@@ -92,9 +92,14 @@ type SettingOption = {
|
||||
current?: boolean;
|
||||
|
||||
/**
|
||||
* Html string or html element of component
|
||||
* Custom selector list, use in controls
|
||||
*/
|
||||
children?: SettingOption[];
|
||||
selector?: SettingOption[];
|
||||
|
||||
/**
|
||||
* When selector item click, use in controls
|
||||
*/
|
||||
onSelect?(selector: Selector, element: HTMLElement): void;
|
||||
};
|
||||
|
||||
type Component = {
|
||||
|
||||
Reference in new issue
Block a user