• 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

    Video Position Saving

    With FV Player’s Remember Video Position setting the viewer video position is stored in database if the user is logged in. Full description of this setting can be found in: How To Use Video Position Saving

    This article describes how to work with FV Player’s video position data for you custom integrations.

    • Data Structure
    • PHP Functions
    • Legacy Shortcodes

    Data Structure

    Here’s how to access this data so that you can potentially build you own custom integrations with FV Player.

    The wp_fv_player_user_video_positions table stores the user video positions. The columns are:

    • id
    • user_id
    • video_id
    • last_position – value in seconds
    • top_position – value in seconds
    • finished – bool
    • legacy_video_id – used if you are using old shortcodes with src: [fvplayer src="..."]
    • ab_start – AB loop start time (Pro)
    • ab_end – AB loop end time (Pro)
    • last_updated – unix timestamp of last update of the row

    So to get last user video position in a video you can use the PHP code:

    global $wpdb;
    $video_position = $wpdb->get_var( $wpdb->prepare( "SELECT last_position FROM {$wpdb->prefix}fv_player_user_video_positions WHERE user_id = %d AND video_id = %s", get_current_user_id(), $video_id ) );

    Since this information is stored for each video, it’s a bit tricky to figure out which video is used in any given player or a post.

    Here’s how to loop through the player videos:

    $player = new FV_Player_Db_Player( $player_id );
    if( $player && $player->getIsValid() ) {
      $videos = $player->getVideos();
      foreach( $videos AS $video ) {
        echo "<p>Video #".$video->getId()." has duration of ".$video->getDuration().".</p>
    n";
      }
    }

    If you are showing a post, it’s also possible to obtain the videos which belong to players embedded in the post:

    global $wpdb;
    $videos_in_this_post = $wpdb->get_results( $wpdb->prepare( "
    SELECT v.id AS id, vm.meta_value AS duration FROM
      {$wpdb->prefix}fv_player_players AS p
    JOIN {$wpdb->prefix}fv_player_playermeta AS pm
      ON p.id = pm.id_player
    JOIN {$wpdb->prefix}fv_player_videos AS v
      ON FIND_IN_SET(v.id, p.videos) 
    JOIN {$wpdb->prefix}fv_player_videometa AS vm
      ON v.id = vm.id_video
    WHERE
      pm.meta_key = 'post_id' AND
      pm.meta_value = %d AND
      vm.meta_key = 'duration'", $post_id ) );
    
    foreach( $videos_in_this_post AS $video ) {
      echo "<p>Video #".$video->id." has duration of ".$video->duration.".</p>
    n";
    }

    The query is a bit tricky, it gets the videos for which:

    • the player has a playermeta key post_id with value matching your $post_id
    • the video must be among the player’s videos IDs
    • the video must have the duration stored in videometa table

    This way you know the video ID, its duration and you can obtain user position in that video using get_user_meta() as shown above.

    PHP Functions

    The above structure is not exactly simple, so FV Player provides ready-to-go functions to get a list of the watched video IDs or the post IDs where they belong.

    function fv_player_get_user_watched_video_ids( $args = array() )

    Gives back an array of video IDs, or array of video progress details.

    Parameters

    $args array Optional

    • count int Number of items to get
    • full_details bool Should it return full details about the video progress?
    • include string Get only “unfinished” or “finished” videos.
    • post_type string Post type where the video is embed
    • user_id int User ID to operate on, defaults to logged in user.

    Return

    array Array of video IDs, or array of video progress details.

    Example when using $args = array( 'full_details' => true ):

    array(
      1 => array(
        'type' => 'unfinished',
        'message' => 'Watched until 00:30',
        'player_id' => 1,
        'post_id' => 100,
        'time' => '30'
      ),
      10 => array(
        'type' => 'finished',
        'message' => 'Saw whole video',
        'player_id' => 8,
        'post_id' => 120
      )
    )

    function fv_player_get_user_watched_post_ids( $args = array() )

    Get post IDs where the user has watched a video.

    Parameters

    Same as fv_player_get_user_watched_video_ids().

    Return

    array Array of post IDs where the user has a video that he watched.

    Legacy shortcodes

    If you are using shortcodes like [fvplayer src="https://video-cdn.site.com/course-1/lesson-1-1.mp4"] then it’s a bit tricky.

    The video position is then stored for the video file name. If it’s a HLS stream, it takes the folder name. So these must be unique for this feature to work reliably.

    So the position in https://video-cdn.site.com/course-1/lesson-1-1.mp4 will be stored as fv_wp_flowplayer_position_lesson-1-1 and https://video-cdn.site.com/course-1/lesson-1-1/index.m3u8 will be stored as fv_wp_flowplayer_position_lesson-1-1 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‬