We’ve got the player running as the core foundation for https://theredmentv.com. One strange occurance is a high load on the admin-ajax.php file for an action: fv_wp_flowplayer_video_position_save. Is there a way to slow this down to every 30 seconds?
this could happen if you have a lot of logged in users watching your videos. The video position is stored when you close the browser tab, but also periodically to ensure the position is not lost if your browser crashes or you use some older browser.
To make sure the position is stored less often you can tweak sendPositionsEvery variable in the main plugin JS file, it’s this line: https://github.com/foliovision/fv-wordpress-flowplayer/blob/master/flowplayer/fv-flowplayer.min.js#L2479 The hard coded value is 60 which equals about 15 seconds (might be more, depending on browser and media type). I would suggest you to try a value of 240 there (60 seconds).
This way you should really see an improvement. The performance matters a lot to us, so please let us know how it goes and we will be able to make this a setting. Or we can even provide some code (a mu-plugin) which would disable all the other plugins for these Ajax calls – making them a lot faster.
I have the same concern, happy to see someone else writing it up.
Martin, have you guys considered SHORTINIT approach?
I’m not 100% sure it satisfies all requirements, but maybe?
Btw Delicious Brains also face the same issue https://deliciousbrains.com/wordpress-rest-api-vs-custom-request-handlers/ with their famous WP Migrate DB Pro plugin. Maybe some useful insights in their thoughts?
we could be using SHORTINT, but the problem is that some of the functions would most likely be unavailable:
* is_user_logged_in() and get_current_user_id() – we would have to add some other way of identifying the user, which wouldn’t be as secure as the current approach where the WP login cookie is used and validated by WP itself. So potentially somebody could manipulate other users’ video watch times, unless we do something special to prevent it.
* update_user_meta() – we would have to use low level SQL commands instead, so if somebody would be using WP Object Cache he would be out of luck. But perhaps there is a way of clearing that for the affected users.
Thank you for that deliciousbrains.com link, it’s a great comparison of the options here. I was doing something very similar just the other day.
I think we should start by lowering the amount of these Ajax calls. If we just run them when the user is closing the browser tab or leaving the page it should be reliable enough. The current approach will save your video position even if your browser crashes, but that should be really rare anyway.