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

Foliovision

Making the web work for you

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
Affordable VAST/VPAID for Wordpress has arrived. Serve ads with your videos starting today!
    • Docs
      • Installation
      • Changelog
    • FAQ
    • Support
      • Free Support
      • Pro Support
    • PRO

    Dynamic Content Loading

    Some themes load content using Ajax calls. This is typically used for infinity scrolling and rarely also for the actual navigation on the website.

    • Getting FV Player to load
    • Loading the dynamically added players
    • Problems with JavaScript events?
    • Autoplay

    Getting FV Player to load

    FV Player only loads the scripts if there was a [fvplayer] shortcode used anywhere in the loop,in the widgets or in PHP code.

    If the FV Player is not there and you intend to load content using Ajax make sure you enable Settings -> FV Player -> Integrations/Compatibility -> “Load FV Flowplayer JS everywhere” to make sure the FV Player library is loaded on all pages.

    A much better option is to put this code to the page template where you need FV Player:

    do_action( 'fv_player_force_load_assets');

    That way the JavaScript only loads where it’s necessary.

    Loading the dynamically added players

    FV Player does detect jQuery Ajax calls and will initialize any new players that might be added to the page as a result of the Ajax.

    jQuery(document).ajaxComplete( function() {  
      fv_player_load();
    });

    However if you are not using jQuery for your Ajax you must provide your own hook. Here’s how it works with WPLMS:

    document.addEventListener( 'unit_loaded', function(){
      setTimeout( fv_player_load, 100 );
    });

    unit_loaded is the WPLMS JavaScript event which occurs when loading a new lesson. The timeout is there to make sure the player has been already appended to HTML as the event seems to trigger before the HTML is updated.

    Problems with JavaScript events?

    If there is no JavaScript event to hook into, here’s the last resort – this effectively looks for new FV Player every second and loads it:

    setInterval( fv_player_load, 1000 );

    FV Player could be doing this automatically, or it could be an advanced integration option.

    Autoplay

    If you would like the new appended players to also autoplay, here’s the code:

    document.addEventListener( 'YOUR-EVENT_NAME', function(){
      setTimeout( function() {
        fv_player_load();
    
        // Normally only one autoplay is allowed per page, this unlocks autoplay
        fv_player_did_autoplay = false;
        fv_autoplay_exec();
        jQuery('[data-fvautoplay]').removeAttr('data-fvautoplay');
      }, 100 );
    });

    Allowing autoplay for Ajax loaded content can get problematic if you run these Ajax calls while the main video is still playing.

    Reader Interactions

    Primary Sidebar

    My Account

    • My Licenses
    • My Profile
    • Invoices
    • Affiliate Area
    • Log Out

    For Developers

    1. Why FV Player?
    2. FAQ
    3. Creating and Managing Playlists
    4. Advanced features
    5. Video Security
    6. Troubleshooting
    7. Tools
    8. Analytics
    9. Audio Player
    10. Download | Buy
    11. Getting Started
    12. Setting Screens
    13. Video Hosting
    14. Video Membership, Pay Per View and eLearning
    15. Live Streaming
    16. Video Advertising
    17. FV Player VAST/VPAID
    18. Casting Options
    19. For Developers
      1. FV Player Database
      2. List of Shortcode Parameters
      3. Video Custom Fields
      4. Staging Sites For Developers
      5. AMP
      6. Minify Plugins
      7. Programmer's Guide
      8. JavaScript Guide
      9. Dynamic Content Loading
      10. Video Position Storing
      11. Changelog
      12. How to add your own URL token signing mechanism
    20. FV Player Demos
    21. Additional Services
    22. Legal

    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 © 2023 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 settings.

    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!