With FV Player’s Remember Video Position setting the viewer video position is stored in database if the user is logged in.
Here’s how to access this data so that you can potentially build you own custom integrations with FV Player.
The fv_wp_flowplayer_position_*
user meta key stores the last video position. The value is in seconds:
$video_position = get_user_meta( get_current_user_id(), 'fv_wp_flowplayer_position_'.$video_id, true );
The fv_wp_flowplayer_saw_*
user meta key remembers if the user saw the whole video or not:
$saw_the_video = get_user_meta( get_current_user_id(), 'fv_wp_flowplayer_saw_'.$video_id, true ) );
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.