mirror of
https://github.com/zhw2590582/ArtPlayer.git
synced 2026-10-23 05:41:20 -08:00
add themeMix
This commit is contained in:
1 parent
59400eb3bf
commit
1438ce5e82
16 files changed
+428
-410
No files matched your search
@@ -0,0 +1,32 @@
|
||||
import { def, clamp } from '../utils';
|
||||
|
||||
export default function loopMix(art) {
|
||||
let interval = [];
|
||||
def(art, 'loop', {
|
||||
get: () => interval,
|
||||
set: (value) => {
|
||||
if (Array.isArray(value) && typeof value[0] === 'number' && typeof value[1] === 'number') {
|
||||
const start = clamp(value[0], 0, Math.min(value[1], art.duration));
|
||||
const end = clamp(value[1], start, art.duration);
|
||||
if (end - start >= 1) {
|
||||
interval = [start, end];
|
||||
art.emit('loop', interval);
|
||||
} else {
|
||||
interval = [];
|
||||
art.emit('loop');
|
||||
}
|
||||
} else {
|
||||
interval = [];
|
||||
art.emit('loop');
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
art.on('video:timeupdate', () => {
|
||||
if (interval.length) {
|
||||
if (art.currentTime < interval[0] || art.currentTime > interval[1]) {
|
||||
art.seek = interval[0];
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
Reference in new issue
Block a user