Can we use a macro to loop between time A and time B on a YouTube video webpage? For example, Loop between 5s and 13s of this YouTube video, which video id is 5AwdkGKmZ0I.
I've found a javascript snippet that allows us to set up the starting time and the ending time to loop on this video. It only needs us to fill in 3 things: starting seconds, ending seconds, and a YouTube video ID👇🏽
I wonder if we can use a macro starting like this to achieve the looping function on a YouTube page. A macro may look like this Loop AB for a YouTube video.kmmacros (v10.2) (4.6 KB)
For the JavaScript, I just pasted the code in your link into this HTML. The only thing I changed was this
var section = {
start: 0,
end: 64
};
to this, which gets the values from KM variables:
var section = {
start: document.kmvar.Local_start,
end: document.kmvar.Local_end
};
I don't have a lot of time to spend fleshing this out, so you're pretty much on your own. But if you have questions, go ahead and ask. I just might say "I don't have the time".
Hi Dan! Thank you for your time and kind help! I've run your macro on my Mac. It popped up a player and looped the video well. But before playing, it always pops up two windows like this
And it wouldn't go away when choosing an app like Google Chrome, IINA video player or QuickTime Player to open the video. PS: My mac version is Monterey 12.6; Keyboard Maestro V10.2.
Besides, can we achieve an AB loop on a real YouTube page? Like a webpage opened on a Google Chrome browser? That's why I uploaded this macro
It allowed me to change the start_seconds and end_seconds through Keyboard Maestro to loop the video. But the video_id didn't work. So what's the problem here, may I ask? It looks like something needs to be fixed. The player doesn't recognize the video_id that I assigned to it on line 29▼