mirror of
https://github.com/zhw2590582/ArtPlayer.git
synced 2026-10-28 02:01:20 -08:00
Refactor progress event handling in progress.js
- Moved the 'video:progress' event listener to be consistent with the RAF and timeupdate events. - Ensured 'setBar' for 'loaded' is emitted during both RAF and video:progress events. - Cleaned up the structure for better readability and maintainability.
This commit is contained in:
1 parent
9bdaaa3b7d
commit
674c6420e9
3 files changed
+1132
-1110
No files matched your search
@@ -125,23 +125,24 @@ export default function progress(options) {
|
||||
art.on('setBar', setBar);
|
||||
art.on('video:loadedmetadata', updateHighlight);
|
||||
|
||||
art.on('video:progress', () => {
|
||||
art.emit('setBar', 'loaded', art.loaded);
|
||||
});
|
||||
|
||||
if (art.constructor.USE_RAF) {
|
||||
art.on('raf', () => {
|
||||
art.emit('setBar', 'played', art.played);
|
||||
art.emit('setBar', 'loaded', art.loaded);
|
||||
});
|
||||
} else {
|
||||
art.on('video:timeupdate', () => {
|
||||
art.emit('setBar', 'played', art.played);
|
||||
});
|
||||
}
|
||||
|
||||
art.on('video:ended', () => {
|
||||
art.emit('setBar', 'played', 1);
|
||||
});
|
||||
art.on('video:progress', () => {
|
||||
art.emit('setBar', 'loaded', art.loaded);
|
||||
});
|
||||
|
||||
art.on('video:ended', () => {
|
||||
art.emit('setBar', 'played', 1);
|
||||
});
|
||||
}
|
||||
|
||||
art.emit('setBar', 'loaded', art.loaded || 0);
|
||||
|
||||
|
||||
Reference in new issue
Block a user