Question
Problem with increasing stream delay time on client
Hi,
Iam having this problem:
Iam running tv-like app which streams bunch of videos; after last video in row finishes, app loads new videoloop from xml and starts stream again. When a client connects, everything works just fine with 1 exception: the clients stream is slowly increasing delay from source. Ive tried to check netStream.bufferLength during playing (its set to 3s on the beginning) and i found out, thats its slowly growing. - after like 5 minutes of playing its around 30s; my only suggestion is, that client isnt playing video fast enough... which sounds kinda stupid to me... (ive checked this on many systems / networks and iam pretty sure it has nothing to do with processor/network overload) please, anyone could have solution for this ?Any help would be highly appreciated.
Thanks,
J.S.
Application code is here:
application.allowDebug = true;
application.onAppStart = function() {
trace("STREAM>>> Application TV stream started");
application.loopArray = new Array();
application.videoIndex = -1;
application.clientStream = Stream.get("tvStream");
loadXml("loop.xml");
application.clientStream.onStatus = function(str) {
switch (str.code) {
case "NetStream.Play.Stop":
loadXml("loop.xml");
break;
case "NetStream.Play.Start":
application.videoIndex++;
trace("STREAM>>> playing video "+application.loopArray[application.videoIndex][0]+" videoindex= "+application.videoIndex);
break;
case "NetStream.Play.Reset":
application.videoIndex = -1;
trace("STREAM>>> Stream restarted");
break;
}
//trace(str.code);
}
function setStream(vidArray) {
for (var i=0;i<vidArray.length;i++) {
var repeat=false;
/*if (i==0) {
repeat = true;
} else {
repeat = false;
}*/
application.clientStream.play(vidArray [0],0,-1,repeat);
}
}
function loadXml(target2load) {
application.loopArray = new Array();
var xml = new XML();
xml.ignoreWhite = true;
xml.onLoad = function(succes) {
for (var i = 0; i < xml.firstChild.childNodes.length; i++) {
application.loopArray = new Array();
application.loopArray .push(xml.firstChild.childNodes.attributes.poradpath);
application.loopArray .push(xml.firstChild.childNodes.attributes.id);
application.loopArray .push(xml.firstChild.childNodes.attributes.desc);
application.loopArray .push(xml.firstChild.childNodes.attributes.name);
application.loopArray .push(xml.firstChild.childNodes.attributes.dil);
}
application.videoIndex = -1;
setStream(application.loopArray);
trace("SERVER>>> XML loaded - starting stream");
}
xml.load(target2load);
}
}
application.onConnect = function(clientObj) {
application.acceptConnection(clientObj);
clientObj.call("getPlayedFileInfo",null,application.setVidInfo());
// trace("CLIENT>>> Client connected: IP="+clientObj.ip+" | ID="+clientObj.id+" | referrer="+clientObj.referrer);
}
application.onDisconnect = function(clientObj) {
// trace("CLIENT>>> Client disconnected: IP="+clientObj.ip+" | ID="+clientObj.id);
}
application.setVidInfo = function() {
// trace(application.loopArray[application.videoIndex]);
return application.loopArray[application.videoIndex].slice(1,application.loopArray[application.videoIndex].length);
}
Client.prototype.sendVidInfo = function() {
this.call("getPlayedFileInfo",null,application.setVidInfo());
}
Iam having this problem:
Iam running tv-like app which streams bunch of videos; after last video in row finishes, app loads new videoloop from xml and starts stream again. When a client connects, everything works just fine with 1 exception: the clients stream is slowly increasing delay from source. Ive tried to check netStream.bufferLength during playing (its set to 3s on the beginning) and i found out, thats its slowly growing. - after like 5 minutes of playing its around 30s; my only suggestion is, that client isnt playing video fast enough... which sounds kinda stupid to me... (ive checked this on many systems / networks and iam pretty sure it has nothing to do with processor/network overload) please, anyone could have solution for this ?Any help would be highly appreciated.
Thanks,
J.S.
Application code is here:
application.allowDebug = true;
application.onAppStart = function() {
trace("STREAM>>> Application TV stream started");
application.loopArray = new Array();
application.videoIndex = -1;
application.clientStream = Stream.get("tvStream");
loadXml("loop.xml");
application.clientStream.onStatus = function(str) {
switch (str.code) {
case "NetStream.Play.Stop":
loadXml("loop.xml");
break;
case "NetStream.Play.Start":
application.videoIndex++;
trace("STREAM>>> playing video "+application.loopArray[application.videoIndex][0]+" videoindex= "+application.videoIndex);
break;
case "NetStream.Play.Reset":
application.videoIndex = -1;
trace("STREAM>>> Stream restarted");
break;
}
//trace(str.code);
}
function setStream(vidArray) {
for (var i=0;i<vidArray.length;i++) {
var repeat=false;
/*if (i==0) {
repeat = true;
} else {
repeat = false;
}*/
application.clientStream.play(vidArray [0],0,-1,repeat);
}
}
function loadXml(target2load) {
application.loopArray = new Array();
var xml = new XML();
xml.ignoreWhite = true;
xml.onLoad = function(succes) {
for (var i = 0; i < xml.firstChild.childNodes.length; i++) {
application.loopArray = new Array();
application.loopArray .push(xml.firstChild.childNodes.attributes.poradpath);
application.loopArray .push(xml.firstChild.childNodes.attributes.id);
application.loopArray .push(xml.firstChild.childNodes.attributes.desc);
application.loopArray .push(xml.firstChild.childNodes.attributes.name);
application.loopArray .push(xml.firstChild.childNodes.attributes.dil);
}
application.videoIndex = -1;
setStream(application.loopArray);
trace("SERVER>>> XML loaded - starting stream");
}
xml.load(target2load);
}
}
application.onConnect = function(clientObj) {
application.acceptConnection(clientObj);
clientObj.call("getPlayedFileInfo",null,application.setVidInfo());
// trace("CLIENT>>> Client connected: IP="+clientObj.ip+" | ID="+clientObj.id+" | referrer="+clientObj.referrer);
}
application.onDisconnect = function(clientObj) {
// trace("CLIENT>>> Client disconnected: IP="+clientObj.ip+" | ID="+clientObj.id);
}
application.setVidInfo = function() {
// trace(application.loopArray[application.videoIndex]);
return application.loopArray[application.videoIndex].slice(1,application.loopArray[application.videoIndex].length);
}
Client.prototype.sendVidInfo = function() {
this.call("getPlayedFileInfo",null,application.setVidInfo());
}
