rendered paste body
function stream_video()
{
// view set to (Math.pow(view_format, 2) so it points to last view, so next properly cached view is 1
this.stream = {cache_jpeg: new Array(), cache_num: 0, view: 0, try_count: 0};
this.stream.cache_jpeg[0] = new Array();
this.stream.cache_jpeg[1] = new Array();
for (i=0; i<16; i++)
{
this.stream.cache_jpeg[0][i] = new Image();
this.stream.cache_jpeg[1][i] = new Image();
}
this.cache = cache();
this.show = show();
}
function cache()
{
this.stream.try_count = 0;
while (true)
{
this.stream.cache_num = (this.stream.cache_num == 1)?0:1; // Toggle cache_num
this.stream.view = (this.stream.view > (Math.pow(view_format, 2)))?1:this.stream.view++;
this.stream.feed = parent.state_view_seqs[view_format][this.stream.view];
// Don't bother with 'no video' views
if (this.stream.feed <= parent.state_video_feeds)
{
// Don't look ahead for single view
var next_view = this.stream.view + 1
if (next_view > (Math.pow(view_format, 2))) next_view = 1;
var next_feed = parent.state_view_seqs[view_format][next_view];
// Use workaround so ajaxget executed before caching + screen out
// white screen on first view at startup
var jpeg_file = (ajax_reply == "")?"misc/caching.jpeg":ajax_reply;
ajaxget(next_feed);
this.stream.cache_jpeg[this.stream.cache_num][this.stream.view].src = jpeg_file;
window.setTimeout("show(" + this.stream + ")", 1);
break;
}
}
}
function show()
{
if (this.stream.cache_jpeg[this.stream.cache_num][this.stream.view].complete)
{
// If this.stream view is the last view changed, cache it for a cycle
if (view_change == this.stream.view)
{
cache_jpeg[this.stream.cache_num][this.stream.view].src = "misc/caching.jpeg";
view_change = 0;
}
document.getElementById("image_" + this.stream.view).src = cache_jpeg[this.stream.cache_num][this.stream.view].src;
this.stream.try_count = 0;
window.setTimeout("this.stream_video(" + this.stream + ")", 75);
}
else
{
// If cache_jpeg is not completely downloaded, keep trying ...
this.stream.try_count++;
if (this.stream.try_count > 10000) window.setTimeout("this.stream_video(" + this.stream + ")", 1);
window.setTimeout("show(" + this.stream + ")", 25);
}
}