JavaScript YouTube video playing detection determination

Detect Playing YouTube Video in JavaScript

This article introduces how to determine whether an HTML5 video is playing on YouTube using the JavaScript programming language. Checking if an HTML5 video is playing with an if statement. <pre><code>Object.defineProperty(HTMLMediaElement.prototype, 'playing…

Shou Arisaka
1 min read
Nov 22, 2025

This article introduces how to determine whether an HTML5 video is playing on YouTube using the JavaScript programming language.

Checking if an HTML5 video is playing with an if statement.

Object.defineProperty(HTMLMediaElement.prototype, 'playing', {
    get: function(){
        return !!(this.currentTime > 0 && !this.paused && !this.ended && this.readyState > 2);
    }
})

if(document.querySelector('#movie_player > div.html5-video-container > video').playing){
    console.log('true') ;
}

Summary

This time we introduced how to determine whether an HTML5 video is playing using the Object.defineProperty method.

Share this article

Shou Arisaka Nov 22, 2025

🔗 Copy Links