123GoToAndPlay
%Europe/Berlin %414 %2008, 10:56
Zit een beetje in een loop na te denken :(
Ik probeer een simpele FlvPlayer class te maken, maar ik heb problemen met de variable duration. (Het is toch geen scope probleem aangezien ik de var buiten de functie al declareer?)
class FlvPlayer extends MovieClip {
var duration:Number;
public function playVideo():Void {
//var duration:Number;
if(!isStarted) {
theVideo.attachVideo(ns);
ns.play(videoURL);
//theVideo.smoothing = smooth;
isStarted = true;
} else {
ns.pause();
}
//
ns.setBufferTime(30);
ns.onStatus = function(info) {
if(info.code == "NetStream.Buffer.Full") {
trace( "NetStream.Buffer.Full");
_root.bufferClip._visible = false;
}
if(info.code == "NetStream.Buffer.Empty") {
trace( "NetStream.Buffer.Empty");
_root.bufferClip._visible = true;
}
if(info.code == "NetStream.Play.Stop") {
ns.seek(0);
}
}
//duration
ns.onMetaData = function(obj) {
duration = obj.duration;
trace(" Duration A:"+duration);
}
trace("Duration B: "+duration);
//call videostatus with our netstream
videoInterval = setInterval(videoStatus, 100, ns, duration);
_root.playBtn._visible = false;
_root.pauseBtn._visible = true;
}
........
}
Duration A wordt wel getraced maar Duration B niet? Duration wordt in een andere functie videoStatus weer gebruikt.
Hoe los ik die op?
Bij voorbaat dank
Ik probeer een simpele FlvPlayer class te maken, maar ik heb problemen met de variable duration. (Het is toch geen scope probleem aangezien ik de var buiten de functie al declareer?)
class FlvPlayer extends MovieClip {
var duration:Number;
public function playVideo():Void {
//var duration:Number;
if(!isStarted) {
theVideo.attachVideo(ns);
ns.play(videoURL);
//theVideo.smoothing = smooth;
isStarted = true;
} else {
ns.pause();
}
//
ns.setBufferTime(30);
ns.onStatus = function(info) {
if(info.code == "NetStream.Buffer.Full") {
trace( "NetStream.Buffer.Full");
_root.bufferClip._visible = false;
}
if(info.code == "NetStream.Buffer.Empty") {
trace( "NetStream.Buffer.Empty");
_root.bufferClip._visible = true;
}
if(info.code == "NetStream.Play.Stop") {
ns.seek(0);
}
}
//duration
ns.onMetaData = function(obj) {
duration = obj.duration;
trace(" Duration A:"+duration);
}
trace("Duration B: "+duration);
//call videostatus with our netstream
videoInterval = setInterval(videoStatus, 100, ns, duration);
_root.playBtn._visible = false;
_root.pauseBtn._visible = true;
}
........
}
Duration A wordt wel getraced maar Duration B niet? Duration wordt in een andere functie videoStatus weer gebruikt.
Hoe los ik die op?
Bij voorbaat dank