How to loop a segment of a video?
-
I want to loop a video on a third party site.
but I don't know where the video file is or how it is managed.
there is only video-elemet. and a bunch of divs in it
So I decided to just simulate the timeline click with an interval
jQuery(Document.getElementsByClassName('mhp1138_progressPadding').elementFromPoint(x, y)).click(); } function tick() { console.log('tesr'); simulateClick(100, 30); } setInterval(tick, 100);
JavaScript Anonymous, Jul 25, 2019 -
- (Can be skipped) Select the element with the mouse in the developer tools in the tree It is now available in the console via the $ 0 alias
- Store the link to the video element into a variable. (via $ 0 or search for an element)
- Write a setInterval function that specifies v.currentTime =% the second of the video you want%
- In the interval, specify the period that interests you.
- Profit.
const v = $0 // или вместо $0 document.querySelector... - получить элемент video
let startTime = 15 // 15ая секунда видео - секунда, с которой будет начинаться цикл
let duration = 1000 // 1000 миллисекунд = 1 секунда - продолжительность цикла
const repeat = setInterval(function () {
v.currentTime = startTime
}, duration)Josephine Hernandez - (Can be skipped) Select the element with the mouse in the developer tools in the tree It is now available in the console via the $ 0 alias
1 Answers
Your Answer
To place the code, please use CodePen or similar tool. Thanks you!