I am developing a plugin to create a slideshow for videos, with support for Vimeo and Youtube, I am using this plugin https://github.com/faktorvier/jquery-video to create the controls, the html version of my plugin works perfectly Well, but the version for WordPress has the following error “Uncaught TypeError: Can not read property ‘video’ of undefined
At onYouTubeIframeAPIReady (jquery.video.js: 5) “

The error always points to line 5 in the jquery.video.js file

if(typeof $.video != 'undefined')

The interesting thing is that Vimeo videos work perfectly well, only youtube videos have this error.
Someone could help me, I’ve been trying to figure this out for almost a week.

Below I put my code.

$(function() {       
// Init
$('#videoplay-gallery-<?php echo $id; ?> .video').video();

            // Add events
            $('#videoplay-gallery-<?php echo $id; ?> .video').addVideoEvent('ready', function(e, $video, video_type) {
                $video.next('.status').html('Status: ready');

            $('#videoplay-gallery-<?php echo $id; ?> .video').addVideoEvent('play', function(e, $video, video_type) {
                $video.next('.status').html('Status: playing');
                $video.addClass ('playing-now');

            $('#videoplay-gallery-<?php echo $id; ?> .video').addVideoEvent('pause', function(e, $video, video_type) {
                $video.next('.status').html('Status: paused');                                        

            $('#videoplay-gallery-<?php echo $id; ?> .video').addVideoEvent('finish', function(e, $video, video_type) {
                $video.next('.status').html('Status: finished');

            // Add controls
            // Play Single  
            $('#videoplay-gallery-<?php echo $id; ?> .playone').click(function(e) {                     
                $('#videoplay-gallery-<?php echo $id; ?> .video-current iframe').playVideo();                                                       

            $('#videoplay-gallery-<?php echo $id; ?> .pauseyone').click(function(e) {                                    
                $('#videoplay-gallery-<?php echo $id; ?> .playing-now').pauseVideo(); 

            $('#videoplay-gallery-<?php echo $id; ?> .stop').click(function(e) {
                $('#videoplay-gallery-<?php echo $id; ?> .video').stopVideo();

            $('#videoplay-gallery-<?php echo $id; ?> .mute').click(function(e) {
                $('#videoplay-gallery-<?php echo $id; ?> .video').muteVideo();

            $('#videoplay-gallery-<?php echo $id; ?> .unmute').click(function(e) {
                $('#videoplay-gallery-<?php echo $id; ?> .video').unmuteVideo();


Read more here: Youtube API does not work on WordPress plugin


If you know the solution of this issue, please leave us a reply in Comment section, to update the question.

Wordpress related questions and answers: