Video Embeds
We set a YouTube playlist and play a video from that each time someone visits. To avoid showing them the same (first in the list) video every time they visit, we need a way to make a random one play. So far I have found these:
- http://stackoverflow.com/questions/12831210/
- http://stackoverflow.com/questions/39998539/
- http://stackoverflow.com/questions/23142553/
All slightly different, not sure which will be best.
Found a page with a possibly simple solution, seems to good to be true… [edit] and it is… got me a security lock-out form the ISP. Cross-site scripting. Will look into javascript instead, as php inserted into WP pages seems to be a problem anyway.
https://stackoverflow.com/questions/39998539/make-embedded-youtube-playlist-start-at-random-index – this one works but might be cumbersome as it has to have all the video urls listed in the script. has the advantage of not depending on google’s tendency to destructively ‘upgrade’ everything all the time.
<html> <head> <script> var videos = ["https://www.youtube.com/embed/9bZkp7q19f0", "https://www.youtube.com/embed/dQw4w9WgXcQ"]; window.onload = function () { var playerDiv = document.getElementById("random_player"); var player = document.createElement("IFRAME"); var randomVideoUrl = videos[Math.floor(Math.random() * videos.length)]; player.setAttribute('width', '640'); player.setAttribute('height', '390'); player.setAttribute('src', randomVideoUrl); playerDiv.appendChild(player); }; </script> </head> <body> <div id="random_player" /> </body> </html>
Above also works in the body of the page, no need to put in the head. Though I have anyway.
Parameters can be added to each video, I tried in the script but it didn’t work. E.g.. https://www.youtube.com/embed/5oeQpdvsQJc?rel=0&autoplay=1
rel=0 stops it showing related vids at the end and autoplay is self-evident. Supported parameters are listed in google’s support pages (until they decide to change everything again…)
https://jsfiddle.net/baivong/0k22yw81/ might work but is beyond me.
Anti-Bot
We can also use these videos to hold a unique captcha system which will be difficult for bots to beat. If the code is contained in the video it will be fairly easy to just get them all, as it will be hard to change them without uploading the video again, but if we use the overlays provided by YouTube we can change them more easily. This means we need a way to change them in the script too, some kind of interface.
The YouTube channel can’t be monetized as I originally thought; google will just wait till we have a good bit of money stashed then tell us we violated their TOS and keep it all, and we will have gone through their tedious and lengthy processes for nothing.
How to make the video part of an anti-bot thing?
Having a unique antibot system will help-[ a lot, as it’s less likely botters will bother to overcome it just for one faucet.
- Add an annotation to the videos with a code to be entered in the site before anyone is allowed to claim.
- Doing it this way means manually changing the anti-bot in the script and changing all the vids each time I want to change it. Obviously an automated system would be preferable.
- Ideal would be to have a different code in each video but I have no idea how to implement that in the script.
- In any case this plug-in wants 12 euro a month for the version that does anything useful… still, its a step.
Temporary solutions.
- We can password protect a page in wordpress. If necessary to have subpages with the protections as well, the smart passworded pages plugin will do that, but I think we only need the faucet page to be protected.
- Use TubeBuddy to change the annotation in the videos to show the password.
- Use wp maintenance mode plugin as well, with countdown timer:
- open youtube channel to the right page
- change annotation in youtube
- change password in faucet page
- not ideal but will see how it goes with the change over. See if password change affects users already in the page.