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

Foliovision

  • 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 6 years, 4 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

How to …

    Categories

    • Business
    • Camera Reviews
    • Case Studies
    • Design
    • FV Player
    • Internet Marketing
    • IT
    • Life
    • SEO
    • Slovak
    • Video of the Week
    • WordPress

    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 © 2026 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‬