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

    How to add your own URL token signing mechanism

    Using URL tokens for your videos is the basic step of protecting your videos against sharing on other websites.

    This function is typically provided by the video CDNs, such as Bunny CDN, KeyCDN or AWS CloudFront.

    If you are using your own custom URL tokens, here’s how you can make sure FV Player Pro can work with these:

    <?php add_action( 'plugins_loaded', function() {
      if( !class_exists('FV_Player_Pro_Ajax_Loader') ) return;
    
      class FV_Player_Pro_CustomCDN extends FV_Player_Pro_Ajax_Loader {
    
        function __construct() {  
          // set these if you don't need settings box:
          //$this->aDomains = array( 'domain1.your-cdn.com', 'domain2.your-cdn.com' );
          //$this->aSecureTokens = array( 'key-for-domain-1', 'key-for-domains-2' );
    
          // Use if your target video is HLS, without it the video URL will not load using Ajax
          //add_filter( 'fv_flowplayer_get_mime_type', array( $this, 'set_file_type' ), 10 , 2 );
    
          parent::__construct( array( 'key' => 'customcdn', 'title' => 'My Custom CDN' ) );
        }
    
        // This function returns the URL query argument your tokens are using
        function args($args) {
          $args[] = 'token';
          return $args;
        }
    
        function secure_link( $url, $securityKey, $ttl = false ) {
          $parsed = parse_url( $url );
          $expires = time() + ( $ttl ? $ttl : apply_filters('fv_player_secure_link_timeout', 900) );
          $hashableBase = $securityKey.urldecode($parsed['path']).$expires;
    
          // If using IP validation
          // $hashableBase .= "146.14.19.7";    
          $token = md5($hashableBase, true);
          $token = base64_encode($token);
          $token = strtr($token, '+/', '-_');
          $token = str_replace('=', '', $token);  
    
          $url = add_query_arg( 'token', $token, $url);
          $url = add_query_arg( 'expires', $expires, $url);
    
          return $url;
        }
    
        function set_file_type( $type, $src ) {
          foreach ( $this->aDomains as $domain ) {
            if ( stripos( $src, $domain ) !== false ) {
              // This video type is require for FV Player Pro Ajax loading
              $type = "video/fv-mp4";
    
              // FV Player needs to know to load HLS.js
              global $fv_fp;
              $fv_fp->load_hlsjs = true;
            }
          }
    
          return $type;
        }
    
      }
    
      new FV_Player_Pro_CustomCDN;
    
    }, 0 );
    
    

    When you add the above code you should see a new “My Custom CDN” box added to wp-admin -> FV Player Pro -> Hosting. There you will be able to enter your domain and signing key.

    You can also use the this->aDomains and $this->aSecureTokens properties to hard-code it if it does not change.

    Based on the domain which you configure FV Player Pro will run the admin-ajax.php call when playing the video to get the playable video URL.

    If your target video is HLS, you have to uncomment the fv_flowplayer_get_mime_type filter hook too.

    Primary Sidebar

    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. Live Streaming
    11. Download | Buy
    12. Getting Started
    13. Licensing and Account
    14. Setting Screens
    15. Video Hosting
    16. Video Membership, Pay Per View and eLearning
    17. Video Advertising
    18. FV Player VAST/VPAID
    19. Casting Options
    20. For Developers
      1. FV Player 8 Changes
      2. FV Player Database
      3. Lightbox Customizations
      4. List of Shortcode Parameters
      5. Video Custom Fields
      6. AMP
      7. Minify Plugins
      8. API | Programmer's Guide
      9. JavaScript Guide
      10. Dynamic Content Loading
      11. Video Position Saving
      12. Changelog
      13. How to add your own URL token signing mechanism
      14. How to change FV Player Translations and Labels
    21. FV Player Demos
    22. Additional Services
    23. 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 © 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‬