I am creating a website that gets random videos from the db.
My problem is that my code to get the random video is this:
select id,content from videos order by rand() limit 1
And I don’t want the user to see the same video until 3 other videos (at least) were played before.
Do you have any suggestion on how to do that?
This is how my site works currently.
- HTML-AJAX(CALL FOR VIDEO URL)
- PHP(RETURN RANDOM VIDEO URL) One video.
- AJAX(DISPLAY VIDEO)
[EDITED]
Another problem I am facing is that I need to return only one video url,
because this is how my ajax call look like:
success: function(data){
$('#content').html('<div id="ytapiplayer">You need Flash player 8+ and JavaScript enabled to view this video.</div>');
var params = { allowScriptAccess: "always" };
var atts = { id: "ytapiplayer" };
swfobject.embedSWF(data.vidData+"&enablejsapi=1&playerapiid=ytapiplayer?autoplay=1", "ytapiplayer", "500", "405", "8", null, null, params, atts);
}
Thanks in advance.
Could the video id be sent to the client? Then from there the client (Javascript) request the video. Here how that could be played:
In javascript it might look like :