remove art.once('video:loadedmetadata')

This commit is contained in:
Harvey committed 2022-05-18 11:29:05 +08:00
1 parent e225966202
commit f160d8eb61
10 files changed
+372 -396

No files matched your search

+3 -6
View File
@@ -11,15 +11,12 @@ export default class Contextmenu extends Component {
constructor(art) {
super(art);
this.art = art;
this.name = 'contextmenu';
this.$parent = art.template.$contextmenu;
art.once('video:loadedmetadata', () => {
if (!isMobile) {
this.init();
}
});
if (!isMobile) {
this.init();
}
}
init() {
+105 -102
View File
@@ -20,7 +20,6 @@ export default class Control extends Component {
this.name = 'control';
const {
option,
constructor,
events: { proxy },
template: { $player },
@@ -43,119 +42,123 @@ export default class Control extends Component {
}
});
art.once('video:loadedmetadata', () => {
this.add(
progress({
name: 'progress',
disable: option.isLive,
position: 'top',
index: 10,
}),
);
this.init();
}
this.add(
thumbnails({
name: 'thumbnails',
disable: !option.thumbnails.url || option.isLive || isMobile,
position: 'top',
index: 20,
}),
);
init() {
const { option } = this.art;
this.add(
loop({
name: 'loop',
disable: false,
position: 'top',
index: 30,
}),
);
this.add(
progress({
name: 'progress',
disable: option.isLive,
position: 'top',
index: 10,
}),
);
this.add(
playAndPause({
name: 'playAndPause',
disable: false,
position: 'left',
index: 10,
}),
);
this.add(
thumbnails({
name: 'thumbnails',
disable: !option.thumbnails.url || option.isLive || isMobile,
position: 'top',
index: 20,
}),
);
this.add(
volume({
name: 'volume',
disable: false,
position: 'left',
index: 20,
}),
);
this.add(
loop({
name: 'loop',
disable: false,
position: 'top',
index: 30,
}),
);
this.add(
time({
name: 'time',
disable: option.isLive,
position: 'left',
index: 30,
}),
);
this.add(
playAndPause({
name: 'playAndPause',
disable: false,
position: 'left',
index: 10,
}),
);
this.add(
quality({
name: 'quality',
disable: option.quality.length === 0,
position: 'right',
index: 10,
}),
);
this.add(
volume({
name: 'volume',
disable: false,
position: 'left',
index: 20,
}),
);
this.add(
screenshot({
name: 'screenshot',
disable: !option.screenshot || isMobile,
position: 'right',
index: 20,
}),
);
this.add(
time({
name: 'time',
disable: option.isLive,
position: 'left',
index: 30,
}),
);
this.add(
setting({
name: 'setting',
disable: !option.setting,
position: 'right',
index: 30,
}),
);
this.add(
quality({
name: 'quality',
disable: option.quality.length === 0,
position: 'right',
index: 10,
}),
);
this.add(
pip({
name: 'pip',
disable: !option.pip,
position: 'right',
index: 40,
}),
);
this.add(
screenshot({
name: 'screenshot',
disable: !option.screenshot || isMobile,
position: 'right',
index: 20,
}),
);
this.add(
fullscreenWeb({
name: 'fullscreenWeb',
disable: !option.fullscreenWeb,
position: 'right',
index: 50,
}),
);
this.add(
setting({
name: 'setting',
disable: !option.setting,
position: 'right',
index: 30,
}),
);
this.add(
fullscreen({
name: 'fullscreen',
disable: !option.fullscreen,
position: 'right',
index: 60,
}),
);
this.add(
pip({
name: 'pip',
disable: !option.pip,
position: 'right',
index: 40,
}),
);
for (let index = 0; index < option.controls.length; index++) {
this.add(option.controls[index]);
}
});
this.add(
fullscreenWeb({
name: 'fullscreenWeb',
disable: !option.fullscreenWeb,
position: 'right',
index: 50,
}),
);
this.add(
fullscreen({
name: 'fullscreen',
disable: !option.fullscreen,
position: 'right',
index: 60,
}),
);
for (let index = 0; index < option.controls.length; index++) {
this.add(option.controls[index]);
}
}
add(getOption) {
+6 -8
View File
@@ -14,14 +14,12 @@ export default class Events {
this.loadImg = this.loadImg.bind(this);
if (art.whitelist.state) {
art.once('video:loadedmetadata', () => {
clickInit(art, this);
hoverInit(art, this);
mousemoveInit(art, this);
resizeInit(art, this);
gestureInit(art, this);
viewInit(art, this);
});
clickInit(art, this);
hoverInit(art, this);
mousemoveInit(art, this);
resizeInit(art, this);
gestureInit(art, this);
viewInit(art, this);
}
}
+3 -5
View File
@@ -5,11 +5,9 @@ export default class Hotkey {
this.art = art;
this.keys = {};
art.once('video:loadedmetadata', () => {
if (art.option.hotkey && !isMobile) {
this.init();
}
});
if (art.option.hotkey && !isMobile) {
this.init();
}
}
init() {
+4 -5
View File
@@ -5,11 +5,10 @@ export default class Info extends Component {
constructor(art) {
super(art);
this.name = 'info';
art.once('video:loadedmetadata', () => {
if (!isMobile) {
this.init();
}
});
if (!isMobile) {
this.init();
}
}
init() {
+3 -5
View File
@@ -12,10 +12,8 @@ export default class Layer extends Component {
this.name = 'layer';
this.$parent = $layer;
art.once('video:loadedmetadata', () => {
for (let index = 0; index < option.layers.length; index++) {
this.add(option.layers[index]);
}
});
for (let index = 0; index < option.layers.length; index++) {
this.add(option.layers[index]);
}
}
}
+17 -20
View File
@@ -31,7 +31,6 @@ export default class Setting extends Component {
template: { $setting, $player },
} = art;
this.art = art;
this.name = 'setting';
this.$parent = $setting;
@@ -40,31 +39,29 @@ export default class Setting extends Component {
this.cache = new Map();
if (option.setting) {
art.once('video:loadedmetadata', () => {
if (option.playbackRate) {
this.option.push(playbackRate(art));
}
if (option.playbackRate) {
this.option.push(playbackRate(art));
}
if (option.aspectRatio) {
this.option.push(aspectRatio(art));
}
if (option.aspectRatio) {
this.option.push(aspectRatio(art));
}
if (option.flip) {
this.option.push(flip(art));
}
if (option.flip) {
this.option.push(flip(art));
}
if (option.subtitleOffset) {
this.option.push(subtitleOffset(art));
}
if (option.subtitleOffset) {
this.option.push(subtitleOffset(art));
}
for (let index = 0; index < option.settings.length; index++) {
this.option.push(option.settings[index]);
}
for (let index = 0; index < option.settings.length; index++) {
this.option.push(option.settings[index]);
}
this.option = makeRecursion(this.option);
this.option = makeRecursion(this.option);
this.init(this.option);
});
this.init(this.option);
art.on('blur', () => {
if (this.show) {
+1 -3
View File
@@ -9,9 +9,7 @@ export default class Subtitle extends Component {
this.name = 'subtitle';
art.once('video:loadedmetadata', () => {
this.init(art.option.subtitle);
});
this.init(art.option.subtitle);
}
get url() {