Of course, that’s what "Cookies are for": https://developer.mozilla.org/en-US/docs/Web/HTTP/Cookies
I’ve got part of the code on https://www.w3schools.com/js/js_cookies.asp
You just need to create a cookie with the number of hits and then keep picking up the rest of the split of the number of hits by the amount of videos. And so you will know which video will display.
<html>
<head>
<meta charset="utf8">
<script>
// Você pode por o nome que quiser dos vídeos, e quantidade que quiser
var videos = ["v1.mp4", "v2.mp4", "v3.mp4"];
function setCookie(cname,cvalue,exdays) {
var d = new Date();
d.setTime(d.getTime() + (exdays*24*60*60*1000));
var expires = "expires=" + d.toGMTString();
document.cookie = cname + "=" + cvalue + ";" + expires + ";path=/";
}
function getCookie(cname) {
var name = cname + "=";
var decodedCookie = decodeURIComponent(document.cookie);
var ca = decodedCookie.split(';');
for(var i = 0; i < ca.length; i++) {
var c = ca[i];
while (c.charAt(0) == ' ') {
c = c.substring(1);
}
if (c.indexOf(name) == 0) {
return c.substring(name.length, c.length);
}
}
return "";
}
function checkCookie() {
var acessos = getCookie("acessos");
if (acessos != "") {
acessos = parseInt(acessos)+1;
} else {
// Caso queria que sempre seja visto primeiro
// o primeiro vídeo, descomente a próxima linha
//var acessos = 1;
// Ou gerando o priemiro vídeo aletatório, se baseando
// no tamanho do array vídeos
acessos = Math.floor(Math.random() * videos.length);
}
setCookie("acessos", acessos, 30);
setVideo(acessos);
}
function setVideo(acessos) {
var video = videos[acessos % videos.length];
document.getElementById("titulo").innerHTML = video;
var src = document.createElement("source");
src.setAttribute("src", video);
src.setAttribute("type","video/mp4");
var video = document.getElementById("video");
video.appendChild(src);
video.play();
}
</script>
</head>
<body onload="checkCookie()">
<h1 id="titulo"></h1>
<video id="video" width="320" height="240" loop controls>
<p>Seu navegador não suporta o vídeo.</p>
</video>
</body>
</html>
First of all, thank you very much for your attention. Poxa I think I did something wrong because the video the title changes right, I added the videos there all with the name v1, v2, v3, v4 and v5 all in MP4. but it did not run the video, and even if it was another user it should follow the previous user count following the link: https://testewww.000webhostapp.com/teste-nathan/index.html
– Jonathan Santos
It was my mistake. Now, if you want for every user who accesses the site to change the video, you will have to store the number of accesses on the server. But actually this is not too different from randomly choosing a video from the user’s point of view.
– Umo
Again thank you, for the attention and without wanting to abuse too much of your goodwill, have any topic or link that helps me at this point that for me it is important that they follow the order through other users also Example user to enter and watched or is watching v1.mp4 the next user to access b same from another device will enter will watch v2.mp4 and so on.
– Jonathan Santos
Well, now you’re going to show the videos. Now, what are you using on the server side? PHP? Python? Node.js? For me to put the user-specific video example.
– Umo
I use PHP, here on the server
– Jonathan Santos
So I ended up seeing that this way work, but for exactly what I want not to be able to apply well. So what happens. that I will use this html, (into an RB ) and create a hotspot, and every time someone joined this wifi before releasing the internet would present a video and the same continue to forget, for customers who connect later, in my shop. In my head it would be like this html generate a txt inside the folder that it is inside the router and this txt it sends and fetch the value to drop the videos.
– Jonathan Santos