I searched for "how to loop videos on youtube" today

Many websites appeared when music videos first became popular on YouTube, doing what you might imagine YouTube would do for you: looping the video you're playing. I also had no idea what HTML was at the time, thus I couldn't have ever dreamed of creating such an app. Recently, I've been considering it as a potential side business and believed it would be somewhat difficult given that individuals have created elaborate websites specifically for it.

However, I'm not good at side projects, and because of my laziness, I usually just click the first result when I search for "how to loop videos on youtube" I see the error notice, "Playback is now not available," for whatever reason.

Ugh. But even though my earworm (gross term, right?) wasn't going away, I was still embarrassed enough to take action. Today I couldn't stop thinking about the most recent song video by Gambino.

I reasoned that there must be a method to make the HTML audio> tag play the music automatically in my browser console based on my limited knowledge with it. I assumed the video> HTML element had the same play() and pause() functions as the audio> HTML element.

<video

style="width: 853px; height: 480px; left: 280.833px; top: 0px;"

tabindex="-1"

class="video-stream html5-main-video"

controlslist="nodownload"

src="blob:https://www.youtube.com/cbd57a70-6691-bc44-bb4d-3e53926e5df1">

</video>

Those attributes are fascinating, particularly controlslist="nodownload"! But I digress. It's unfortunate that there isn't an ID, but class suffices.

document.getElementsByClassName('video-stream html5-main-video')

Excellent, we're making progress at last.

const video = document.getElementsByClassName('video-stream html5-main-video')[0]

//=> returns the HTML video tag from above

video.play

//=> function play()

// The function exists!

video.play()

// The video started playing!

video.pause()

// The video paused!

Awesome. This was a solid beginning. If I could merely determine the length of the movie, I might be able to use a setTimeout function to play it automatically for me. I might also need an if statement to see whether the start time matches the end time.

Wait. Remain patient. There had to be a simpler method. Programmer here! There must be a simpler approach. So I started looking online for html video element. The developer documentation for Mozilla was my desired second result. My gut told me to stop reading after that and utilize the browser's find and cmd + f to repeat what I needed to know.

No outcomes, "Phrase not detected." Ugh. Grazie, Browser. I actually read while SCROLL was down. So much for a practical answer. So I navigated to what I needed, and there it was under the "Attributes" section:

loop: If set, the browser will automatically seek return to the beginning of the video when it reaches its conclusion.

A boolean, wow! even simpler than I'd anticipated. I return to my YouTube website and inspect and set the video's loop attribute in the console.

Naturally, I had to check to see if it would really loop. I waited on the edge of my seat (literally, mostly because I develop strange sitting patterns) to see if the video would properly repeat loop after clicking to near the conclusion. If you're wondering why I didn't click through to the finish right away, it was probably for an absurd reason. But time was running out. three seconds remain Two seconds remain... There is only one second remaining. 0. The video kept playing!

Read more: Want to youtube loop or jump to the most popular sections?

And there you have it, guys, a way to make YouTube videos loop! I'm pleased with how simple it was and relieved that I don't have to utilize an advertisement-filled website. Given that I frequently use my mouse with one hand while using my other for food, I may create a browser extension that accomplishes this with a single click. Though probably not. Whatever the case, with a little bit of Googling and common sense, I discovered a clever little trick. Gratitude for reading!

Tubeloop's Ownd

0コメント

  • 1000 / 1000