Continue Watching for Custom Players

If you are using a Custom video player, you can hook into the VS Netflix Continue Watching feature using the following setup:

1. Enqueue your custom JS script

Within your functions.php or other script registration file, register a new Javascript / jQuery file.

wp_register_script( 
'your-custom-script-handle',
'/{js-script-directory}',
array('jquery', 'wpvs-user-video-tracking-js'),
{theme-or-plugin-version}, //optional
true // optional
);

*Note: be sure to include the wpvs-user-video-tracking-js within the dependencies array.

2. Add Event Listeners To Your Video Player Object

Within your custom Javascript file, you will need to use your custom video player
API or other method for controlling the video player object. This will vary depending
on which player you are using:

Time Updated Event

Most video players should provide an event that fires when the time of the player
is updated. Add an event listener that fires our update users continue watching
function: 

wpvs_update_users_current_video_time(current_time, video_length)

Both parameters current_time and
video_length are required when calling this function.

The current_time parameter should be the current time of the
video.

The video_length parameter should be the total duration of the
video.

**We highly recommend using a custom interval in addition to the Time Updated event of your video player in order to prevent multiple requests to your server.

For example, within your Time Updated event, use a custom
variable such as 10 (10 seconds) to fire the wpvs_update_users_current_video_time
every 10 seconds, rather than every time the
Time Updated event fires.

Video Player time updated events may fire as often as every 250ms, which would cause the wpvs_update_users_current_video_time function to fire 4 times a second.

Ended Event

The second event listener you should add to your custom video player script is
when the video ends.

When your video player fires an ended event, call the wpvs_update_users_current_video_time
function setting both the current_time and
video_length parameter to the duration of the video. This zeros
the remaining time the current user has on the video, which removes it from their
continue watching list.

wpvs_update_users_current_video_time(video_length, video_length)

Reminder: JW Player, Vimeo, WordPress & YouTube

If you are using our built in JW Player, Vimeo, WordPress or YouTube video players, the Continue Watching functionality is already built in and will fire automatically.