Soluzione JavaScript:
codice:
<!doctype html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>URLLoader</title>
<script type="text/javascript">
var oURLLoader = {
mask: 0,
req: new XMLHttpRequest(),
listener: function () {
oURLLoader.urls = this.responseText.split(/\s+/);
oURLLoader.changeFlag.call(this);
},
changeFlag: function () {
oURLLoader.mask |= 1 << (this === oURLLoader.req);
if (oURLLoader.mask !== 3) { return; }
document.getElementById("video").src = oURLLoader.urls[Math.floor(oURLLoader.urls.length * Math.random())];
}
}
oURLLoader.req.onload = oURLLoader.listener;
oURLLoader.req.open("get", "youtube_urls.txt", true);
oURLLoader.req.send();
onload = oURLLoader.changeFlag;
</script>
</head>
<body>
<iframe id="video" src="" frameborder="0" scrolling="no" height="170" width="190"></iframe>
</body>
</html>
youtube_urls.txt:
codice:
http://www.youtube.com/embed/2i72js7Enfg
http://www.youtube.com/embed/zC-4jKxSwSk
http://www.youtube.com/embed/Xl0WM0EdtEI