mirror of
https://github.com/zhw2590582/ArtPlayer.git
synced 2026-10-18 18:51:55 -08:00
优化视频事件
This commit is contained in:
1 parent
df9fab27eb
commit
9feeb5845c
6 files changed
+166
-86
No files matched your search
@@ -6,6 +6,7 @@ let i18nMap = {
|
||||
'Video info': '视频统计信息',
|
||||
Close: '关闭',
|
||||
'Video load failed': '视频加载失败',
|
||||
'Video loading is aborted': '视频加载被中止',
|
||||
Volume: '音量',
|
||||
Play: '播放',
|
||||
Pause: '暂停',
|
||||
@@ -39,6 +40,7 @@ let i18nMap = {
|
||||
'Video info': '影片統計訊息',
|
||||
Close: '關閉',
|
||||
'Video load failed': '影片載入失敗',
|
||||
'Video loading is aborted': '影片加載被中止',
|
||||
Volume: '音量',
|
||||
Play: '播放',
|
||||
Pause: '暫停',
|
||||
|
||||
@@ -14,12 +14,14 @@ export default class Loading {
|
||||
hide() {
|
||||
const { $loading } = this.art.refs;
|
||||
setStyle($loading, 'display', 'none');
|
||||
console.log('hide');
|
||||
this.art.emit('loading:hide', $loading);
|
||||
}
|
||||
|
||||
show() {
|
||||
const { $loading } = this.art.refs;
|
||||
setStyle($loading, 'display', 'flex');
|
||||
console.log('show');
|
||||
this.art.emit('loading:show', $loading);
|
||||
}
|
||||
}
|
||||
@@ -17,60 +17,42 @@ export default function eventInit(art, player) {
|
||||
player.toggle();
|
||||
});
|
||||
|
||||
art.on('video:loadstart', () => {
|
||||
art.loading.show();
|
||||
config.video.events.forEach(eventName => {
|
||||
proxy($video, eventName, event => {
|
||||
art.emit(`video:${event.type}`, event);
|
||||
});
|
||||
});
|
||||
|
||||
art.on('video:loadedmetadata', () => {
|
||||
if (option.autoSize) {
|
||||
player.autoSize();
|
||||
}
|
||||
});
|
||||
|
||||
art.on('video:loadeddata', () => {
|
||||
art.loading.hide();
|
||||
});
|
||||
|
||||
art.on('video:waiting', () => {
|
||||
art.loading.show();
|
||||
});
|
||||
|
||||
art.on('video:seeking', () => {
|
||||
art.loading.show();
|
||||
art.on('video:abort', () => {
|
||||
notice.show(`${i18n.get('Video loading is aborted')}`);
|
||||
});
|
||||
|
||||
art.on('video:canplay', () => {
|
||||
reconnectTime = 0;
|
||||
if (!firstCanplay) {
|
||||
firstCanplay = true;
|
||||
if (option.autoplay) {
|
||||
player.play();
|
||||
}
|
||||
art.emit('firstCanplay');
|
||||
}
|
||||
|
||||
reconnectTime = 0;
|
||||
art.controls.show();
|
||||
art.mask.show();
|
||||
art.loading.hide();
|
||||
if (option.autoplay) {
|
||||
player.play();
|
||||
}
|
||||
});
|
||||
|
||||
art.on('video:timeupdate', () => {
|
||||
art.isPlaying = true;
|
||||
art.controls.hide();
|
||||
art.mask.hide();
|
||||
});
|
||||
// art.on('video:canplaythrough', () => {
|
||||
|
||||
art.on('video:playing', () => {
|
||||
art.isPlaying = true;
|
||||
art.controls.hide();
|
||||
art.mask.hide();
|
||||
});
|
||||
// });
|
||||
|
||||
art.on('video:pause', () => {
|
||||
art.isPlaying = false;
|
||||
art.controls.show();
|
||||
art.mask.show();
|
||||
});
|
||||
// art.on('video:durationchange', () => {
|
||||
|
||||
// });
|
||||
|
||||
// art.on('video:emptied', () => {
|
||||
|
||||
// });
|
||||
|
||||
art.on('video:ended', () => {
|
||||
art.isPlaying = false;
|
||||
@@ -101,9 +83,73 @@ export default function eventInit(art, player) {
|
||||
}
|
||||
});
|
||||
|
||||
config.video.events.forEach(eventName => {
|
||||
proxy($video, eventName, event => {
|
||||
art.emit(`video:${event.type}`, event);
|
||||
});
|
||||
// art.on('video:loadeddata', () => {
|
||||
|
||||
// });
|
||||
|
||||
art.on('video:loadedmetadata', () => {
|
||||
if (option.autoSize) {
|
||||
player.autoSize();
|
||||
}
|
||||
});
|
||||
|
||||
art.on('video:loadstart', () => {
|
||||
art.loading.show();
|
||||
});
|
||||
|
||||
art.on('video:pause', () => {
|
||||
art.isPlaying = false;
|
||||
art.controls.show();
|
||||
art.mask.show();
|
||||
});
|
||||
|
||||
art.on('video:play', () => {
|
||||
art.isPlaying = true;
|
||||
art.controls.hide();
|
||||
art.mask.hide();
|
||||
});
|
||||
|
||||
art.on('video:playing', () => {
|
||||
art.isPlaying = true;
|
||||
art.controls.hide();
|
||||
art.mask.hide();
|
||||
});
|
||||
|
||||
// art.on('video:progress', () => {
|
||||
|
||||
// });
|
||||
|
||||
// art.on('video:ratechange', () => {
|
||||
|
||||
// });
|
||||
|
||||
art.on('video:seeked', () => {
|
||||
art.loading.hide();
|
||||
});
|
||||
|
||||
art.on('video:seeking', () => {
|
||||
art.loading.show();
|
||||
});
|
||||
|
||||
// art.on('video:stalled', () => {
|
||||
|
||||
// });
|
||||
|
||||
// art.on('video:suspend', () => {
|
||||
|
||||
// });
|
||||
|
||||
art.on('video:timeupdate', () => {
|
||||
art.isPlaying = true;
|
||||
art.controls.hide();
|
||||
art.mask.hide();
|
||||
});
|
||||
|
||||
// art.on('video:volumechange', () => {
|
||||
|
||||
// });
|
||||
|
||||
art.on('video:waiting', () => {
|
||||
art.loading.show();
|
||||
});
|
||||
}
|
||||
@@ -37,13 +37,13 @@ export default {
|
||||
plugins: {
|
||||
type: 'array',
|
||||
child: {
|
||||
type: 'string|function|regexp',
|
||||
type: 'function',
|
||||
},
|
||||
},
|
||||
whitelist: {
|
||||
type: 'array',
|
||||
child: {
|
||||
type: 'function',
|
||||
type: 'string|function|regexp',
|
||||
},
|
||||
},
|
||||
layers: {
|
||||
|
||||
Reference in new issue
Block a user