Skip Navigation

[Resolved] YouTube player not working in pagination slider

This support ticket is created 3 years, 1 month ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Kolkata (GMT+05:30)

This topic contains 14 replies, has 3 voices.

Last updated by nickT-2 3 years, 1 month ago.

Assisted by: Minesh.

Author
Posts
#2195609

Hi,

Back in March 2021 (pre covid ... wow!) ... I had some help from Jamal here https://toolset.com/forums/topic/lightbox-shortcode-not-working-when-you-move-to-the-next-pagination/ .. which was about getting a YouTube player to show in a lightbox correctly for the paginated slides in a post slider. We got it fixed by adding custom JS that fired the plugins js when the pagination completed. The lightbox sizing was also an issue which wasn't quite fixed.

But now I've found a better YouTube player plugin from SmashBalloon, which sorts the lightbox sizing correctly and their shortcode is working great with the post's custom field for the video ID. The only issue left is the same as before, it's not loading up in the paginated slides.

I've been in touch with the support at SmashBalloon and they've said I need to add the js command sby_init() ... they've even demoed it here in a video: hidden link

I've tried the following code in the JS editor, based on Jamal's suggested code:

jQuery( document ).on( 'js_event_wpv_pagination_completed', function( event, data ) {
            // the plugin's code here, e.g.    
               sby_init();
});

Does it look correct?

You can see that it not quite right on my test page here: hidden link ... pls change the (dot) to a . for the link to work.

Thanks
Nick

#2195703

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

Yes - the code you shared looks ok to me.

jQuery( document ).on( 'js_event_wpv_pagination_completed', function( event, data ) {
            // the plugin's code here, e.g.    
               sby_init();
});
#2195741

Hi Minesh,
Thanks for having a look.

Unfortunately it doesn't seem to be working. Are you able to see this at hidden link ... pls change the (dot) to a . for the link to work.

Are you able to tell from the inspector if the Views slider is firing the sby_init(); ?

Thanks
Nick

#2195743

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

You can add the console log to see the JS hook "js_event_wpv_pagination_completed" is fired or not and then check the console log.

For example:

jQuery( document ).on( 'js_event_wpv_pagination_completed', function( event, data ) {

            console.log("HOOK IS FIRED"):
            // the plugin's code here, e.g.    
               sby_init();
});
#2195751

Ok thanks .. I've added that line in the js code.

Is this a log in Chrome when you right click and select inspect?

#2195757

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Yes - you can inspect any element and then click on "Console" tab to see the log.

#2195783

Thanks, I've had a look at it doesn't look happy at all.
When I click Next or Previous buttons, which I have for the pagination, it's triggering off a number of warnings about the Frontend and error messages e.g. "Maximum call stack size exceeded"

#2195787

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Well - I'm not sure what it exactly pointing out as the function you are trying to hook within ajax pagination JS hook is the belongs to third party library/plugin.

You can check with that library/plugin support that you have a hook that you can call it on pagination event:

jQuery( document ).on( 'js_event_wpv_pagination_completed', function( event, data ) {
 
            console.log("HOOK IS FIRED"):
            // the plugin's code here, e.g.    
               sby_init();
});

So, how you can hook their function sby_init(); within it. Does it require any dependency, you can check with them. This is custom code and we offer limited support for such custom edits.

#2195797

Hi,

Thanks, I've asked them and awaiting a reply. But looking at the previous code I was using I've added 'run' in the brackets like this:

jQuery( document ).on( 'js_event_wpv_pagination_completed', function( event, data ) {

            // the plugin's code here, e.g.    
               sby_init('run');
});

And it seems to be working, which is great. But there is like a second or 2 delay for when the video loads up. It's not the smoothest experience. Is it possible to speed the trigger up or to make them load when you click rather than pagination completed the transition?

Thanks

#2195819

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Glad to know that you find a way about how to correctly call the function.

For ajax pagination, we only offer the hook you are using "js_event_wpv_pagination_completed". Unfortunately - I do not have any other solution to offer. You may check with Pro Javascript expert to resolve such complicated custom JS issue.

#2195853

Hi,
That's fine thanks. However there is a new issue. If you play one of the videos it opens up in the lightbox fine and plays. If you close and go to another video, it keeps showing and playing the previous video in the lightbox. You can see this on the test page.

Is this the plugin issue or something to do with the slider?

#2195857

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Its again that plugin as we do not offer any lightbox. We just offer a slider.

#2195967

Yes, but I'm sure you understand that the way the slider loads up paginated content will impact any plugin's output and can therefore be the cause of issues.

I'm awaiting a response from the SmashBalloon support and might be back with some questions.

#2197719

Hello there! Minesh won't be available for a couple of days. If you don't mind, I'll continue with you here.

All I can say right now, is that trying to open a youtube video triggers some Javascript errors. Check this screenshot hidden link

SmashBalloon support is definitely important to solve this issue. However, I'd like to get access to your website and check how the view is built. That will help me get a better picture of the issue, and hopefully, we'll fix it quickly.
Your next reply will be private to let you share credentials safely. ** Make a database backup before sharing credentials. **

#2197735

Hi Jamal,
Hope all is well with you.

It's good news. It is actually working correctly and a video background plug-in elsewhere on the page was causing a conflict.