• Skip to content
  • Skip to primary sidebar
  • Skip to footer

Foliovision

Main navigation

  • Weblog
    • FV Player
    • WordPress
    • Video of the Week
    • Case Studies
    • Business
  • About
    • Testimonials
    • Meet the Team
    • We Support
    • Careers
    • Contact
    • Pricing
  • Products
  • Support
    • FV Player Docs
    • Pro Support
  • Login
  • Basket is empty

Outputs a JavaScript on video start or ends

[Solved]

Foliovision › Forums › FV Player › How to … › Outputs a JavaScript on video start or ends

  • Kendell 5 years, 7 months ago

    Hi,

    I’m trying to execute a piece of javascript code when the video starts/ends.
    The line of code i’d like to execute is the following:

    jQuery(".learndash_mark_complete_button").click();}, 10000);

    I added the code snipet from the programmers guide into my functions file but it doesnt work. Is the following code still working?

    add_action('wp_footer', 'my_fv_flowplayer_scripts',999);
    function my_fv_flowplayer_scripts( $script ) {
      global $post;
      if( get_post_meta( $post->ID, 'tweak_player', true ) ) {
        $args = func_get_args();
        $script .= "
        jQuery('#$args[1]').bind('ready', function() {
            alert( 'Video just started!' );
        });
        ";
      }
      return $script;
    }

    Kindly advise, thanks.

    Regards,

Viewing 6 replies - 1 through 6 (of 6 total)
  • Juraj Kacaba 6 years ago
    Avatar photo

    Hello Kendell,

    I’ve forwarded your question to our Senior programmer Martin since it is JScript related. He’ll get in touch with you tomorrow with more information.

    Thanks for using our player,
    Juraj

    Kendell 6 years ago

    Thanks Juraj Kacaba,

    Looking forward to it.

    Martin 6 years ago

    Hello Kendell,

    actually that part of code is using some filter which was deprecated for a while and then removed. It was not supposed to hook to wp_footer. Sorry about that.

    The good news is that the code which you have to use is simpler, at least as long as it should target all the players. Just check the “How to Add Your Code” chapter here: https://foliovision.com/player/advanced/api-programming#how-to

    Perhaps you can just put that code into your theme footer.php file or modify your theme main JavaScript file, if it’s your own child theme or if you are not going to let WordPress update it.

    Thanks,
    Martin

    Kendell 6 years ago

    Hi Martin,

    Thanks for the clarification.

    I see the new code that you made mention of but i tried nesting it as you’d see below but for some reason it doesn’t work.

    jQuery(document).ready(function() {
        
        jQuery(".lntent-action").css({display: "none"});
        jQuery('.flowplayer').on('fv_track_complete', function(e,api,video_name) {
            
            if( typeof(flowplayer) != "undefined" ) { 
            flowplayer( function(api,root) {
             api.bind('finish', function() {
                jQuery(".lntent-action").css({display: "block"});
                jQuery(".mark_complete_button").click();
                
             });
            });
            }
        
    } );
    
    });
    
    

    Can in be used within the tracking api as used above or is it my syntax error?

    I’m trying to add add the click event only if the video reaches the end but only if the user went all the tv_track tiggers.

    Can you please advise?

    Regards,
    Kendell

    Martin 6 years ago

    Hello Kendell,

    is that fv_track_complete trigger working well?

    If so, then you are not far off – that flowplayer( function(api,root) … part is only executed when loading the player. So you are too late to add a finish event there. Instead you should just bind it to the api variable which is passed to that fv_track_complete callback function, so here’s that code part:

    jQuery('.flowplayer').on('fv_track_complete', function(e,api,video_name) {
      api.bind(....)
    });
    

    Thanks,
    Martin

    Kendell 6 years ago

    Ahh

    Thanks Martin. Understood.

    I’m able to take it from there.

Viewing 6 replies - 1 through 6 (of 6 total)
Reply To: Outputs a JavaScript on video start or ends



Please Sign in or Register to upload files.

Related Posts

  1. API | Programmer’s Guide

  2. Troubleshooting Javascript Errors

    Troubleshooting Javascript Errors

  3. Guía del programador

Primary Sidebar

Sign in Register
FV Player Docs Post New Topic

Welcome

to Foliovision support forums! We'll be happy to provide free support to resolve all the reported bugs. You always can start by specifying your OS and browser and steps to reproduce the bug.

If you need help with the installation on your site, please submit a request for a Pro Support Incident. We'll have you up and running in no time, with detailed instructions on how to resolve your issue yourself in the future.

Facing a hard to solve WordPress problem? On a tight deadline?

Let us take care of it for you
right now.

Pro Support Buy FV Player

Footer

Our Plugins

  • FV WordPress Flowplayer
  • FV Thoughtful Comments
  • FV Simpler SEO
  • FV Antispam
  • FV Gravatar Cache
  • FV Testimonials

Free Tools

  • Pandoc Online
  • Article spinner
  • WordPress Password Finder
  • Delete LinkedIn Account
  • Responsive Design Calculator
Foliovision logo
All materials © 2025 Foliovision s.r.o. | Panská 12 - 81101 Bratislava - Slovakia | info@foliovision.com
  • This Site Uses Cookies
  • Privacy Policy
  • Terms of Service
  • Site Map
  • Contact
  • Tel. ‭+421 2/5292 0086‬

We are using cookies to give you the best experience on our website.

You can find out more about which cookies we are using or switch them off in .

Powered by  GDPR Cookie Compliance
Privacy Overview

This website uses cookies so that we can provide you with the best user experience possible. Cookie information is stored in your browser and performs functions such as recognising you when you return to our website and helping our team to understand which sections of the website you find most interesting and useful.

Necessary Cookies

Strictly Necessary Cookie allow you to log in and download your software or post to forums.

We use the WordPress login cookie and the session cookie.

If you disable this cookie, we will not be able to save your preferences. This means that every time you visit this website you will need to enable or disable cookies again.

Support Cookies

Foliovision.com uses self-hosted Rocket.chat and self-hosted Freescout support desk to provide support for FV Player users. These cookies allow our visitors to chat with us and/or submit support tickets.

We are delighted to recommend self-hosted Rocket.chat and especially Freescout to other privacy-conscious independent publishers who would prefer to self-host support.

Please enable Strictly Necessary Cookies first so that we can save your preferences!

3rd Party Cookies

This website uses Google Analytics and Statcounter to collect anonymous information such as the number of visitors to the site, and the most popular pages.

Keeping this cookie enabled helps us to improve our website.

We reluctantly use Google Analytics as it helps us to test FV Player against popular Google Analytics features. Feel free to turn off these cookies if they make you feel uncomfortable.

Statcounter is an independent Irish stats service which we have been using since the beginning of recorded time, sixteen years ago.

Please enable Strictly Necessary Cookies first so that we can save your preferences!