mirror of
https://github.com/zhw2590582/ArtPlayer.git
synced 2026-10-20 12:11:20 -08:00
更新弹幕demo
This commit is contained in:
1 parent
e8d721f92f
commit
c3f092dc2a
5 files changed
+218
-95
No files matched your search
@@ -85,12 +85,12 @@ export default class Danmuku {
|
||||
const { clientHeight } = this.$player;
|
||||
|
||||
if (typeof value === 'number') {
|
||||
return clamp(value, 10, clientHeight);
|
||||
return clamp(value, 0, clientHeight);
|
||||
}
|
||||
|
||||
if (typeof value === 'string' && value.endsWith('%')) {
|
||||
const ratio = parseFloat(value) / 100;
|
||||
return clamp(clientHeight * ratio, 10, clientHeight);
|
||||
return clamp(clientHeight * ratio, 0, clientHeight);
|
||||
}
|
||||
|
||||
return Danmuku.option.margin[0];
|
||||
@@ -102,12 +102,12 @@ export default class Danmuku {
|
||||
const { clientHeight } = this.$player;
|
||||
|
||||
if (typeof value === 'number') {
|
||||
return clamp(value, 10, clientHeight);
|
||||
return clamp(value, 0, clientHeight);
|
||||
}
|
||||
|
||||
if (typeof value === 'string' && value.endsWith('%')) {
|
||||
const ratio = parseFloat(value) / 100;
|
||||
return clamp(clientHeight * ratio, 10, clientHeight);
|
||||
return clamp(clientHeight * ratio, 0, clientHeight);
|
||||
}
|
||||
|
||||
return Danmuku.option.margin[1];
|
||||
|
||||
@@ -184,18 +184,34 @@ export default function setting(art, danmuku) {
|
||||
html: '播放速度',
|
||||
icon: '',
|
||||
tooltip: '适中',
|
||||
range: [5, 0, 10, 2.5],
|
||||
onRange: function (item) {
|
||||
selector: [
|
||||
{
|
||||
html: '极慢',
|
||||
time: 10,
|
||||
},
|
||||
{
|
||||
html: '较慢',
|
||||
time: 7.5,
|
||||
},
|
||||
{
|
||||
default: true,
|
||||
html: '适中',
|
||||
time: 5,
|
||||
},
|
||||
{
|
||||
html: '较快',
|
||||
time: 2.5,
|
||||
},
|
||||
{
|
||||
html: '极快',
|
||||
time: 1,
|
||||
},
|
||||
],
|
||||
onSelect: function (item) {
|
||||
danmuku.config({
|
||||
speed: item.range,
|
||||
speed: item.time,
|
||||
});
|
||||
return {
|
||||
0: '极快',
|
||||
2.5: '较快',
|
||||
5: '适中',
|
||||
7.5: '较慢',
|
||||
10: '极慢',
|
||||
}[item.range];
|
||||
return item.html;
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -203,18 +219,34 @@ export default function setting(art, danmuku) {
|
||||
html: '字体大小',
|
||||
icon: '',
|
||||
tooltip: '适中',
|
||||
range: [6, 2, 10, 2],
|
||||
onRange: function (item) {
|
||||
selector: [
|
||||
{
|
||||
html: '极小',
|
||||
fontSize: '2%',
|
||||
},
|
||||
{
|
||||
html: '较小',
|
||||
fontSize: '4%',
|
||||
},
|
||||
{
|
||||
default: true,
|
||||
html: '适中',
|
||||
fontSize: '6%',
|
||||
},
|
||||
{
|
||||
html: '较大',
|
||||
fontSize: '8%',
|
||||
},
|
||||
{
|
||||
html: '极大',
|
||||
fontSize: '10%',
|
||||
},
|
||||
],
|
||||
onSelect: function (item) {
|
||||
danmuku.config({
|
||||
fontSize: item.range + '%',
|
||||
fontSize: item.fontSize,
|
||||
});
|
||||
return {
|
||||
2: '极小',
|
||||
5: '较小',
|
||||
6: '适中',
|
||||
8: '较大',
|
||||
10: '极大',
|
||||
}[item.range];
|
||||
return item.html;
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -222,12 +254,34 @@ export default function setting(art, danmuku) {
|
||||
html: '不透明度',
|
||||
icon: '',
|
||||
tooltip: '100%',
|
||||
range: [1, 0, 1, 0.01],
|
||||
onRange: function (item) {
|
||||
selector: [
|
||||
{
|
||||
default: true,
|
||||
opacity: 1,
|
||||
html: '100%',
|
||||
},
|
||||
{
|
||||
opacity: 0.75,
|
||||
html: '75%',
|
||||
},
|
||||
{
|
||||
opacity: 0.5,
|
||||
html: '50%',
|
||||
},
|
||||
{
|
||||
opacity: 0.25,
|
||||
html: '25%',
|
||||
},
|
||||
{
|
||||
opacity: 0,
|
||||
html: '0%',
|
||||
},
|
||||
],
|
||||
onSelect: function (item) {
|
||||
danmuku.config({
|
||||
opacity: item.range,
|
||||
opacity: item.opacity,
|
||||
});
|
||||
return Math.floor(item.range * 100) + '%';
|
||||
return item.html;
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -235,17 +289,30 @@ export default function setting(art, danmuku) {
|
||||
html: '显示范围',
|
||||
icon: '',
|
||||
tooltip: '3/4',
|
||||
range: [50, 0, 75, 25],
|
||||
onRange: function (item) {
|
||||
selector: [
|
||||
{
|
||||
html: '1/4',
|
||||
margin: ['2%', '75%'],
|
||||
},
|
||||
{
|
||||
html: '半屏',
|
||||
margin: ['2%', '50%'],
|
||||
},
|
||||
{
|
||||
default: true,
|
||||
html: '3/4',
|
||||
margin: ['2%', '25%'],
|
||||
},
|
||||
{
|
||||
html: '满屏',
|
||||
margin: ['2%', '2%'],
|
||||
},
|
||||
],
|
||||
onSelect: function (item) {
|
||||
danmuku.config({
|
||||
margin: ['0%', item.range + '%'],
|
||||
margin: item.margin,
|
||||
});
|
||||
return {
|
||||
0: '满屏',
|
||||
25: '3/4',
|
||||
50: '半屏',
|
||||
75: '1/4',
|
||||
}[item.range];
|
||||
return item.html;
|
||||
},
|
||||
},
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user