getting the time of a streaming video
having difficulty getting the current runtime of a previously-recorded streaming video. i need it so i can trigger events to happen at certain times during the video.
i've got a movieclip with this script attached to it:
Code:
onClipEvent (enterFrame) {
currentTime=_root.myInputStream.time
trace(myInputStream.time);
}
this resides in the same movieclip as my video and the big movieplaying script. once the video is playing i can trace 'myInputStream.time' inside the main script, but i can't seem to detect it from that outside source.
as a reference, here's what i'm using to play the video:
Code:
stop();
// create connection to server
serverName = "rtmp://www.server.com";
videoToLoad = "XWCA01_Broadband";
totalBuffer = 5;
endtime = 79;
nc = new NetConnection();
nc.connect(serverName+"/xacta");
nc.onStatus = function(returnObj) {
if (returnObj.code == "NetConnection.Connect.Success") {
startVideo();
} else if (returnObj.code == "NetConnection.Connect.Rejected") {
gotoAndStop("server busy");
nc.onStatus = null;
} else if (returnObj.code == "NetConnection.Connect.Closed") {
gotoAndStop("closed connection");
}
};
function startVideo() {
myInputStream = new NetStream(nc);
vidBoxPlay.attachVideo(myInputStream);
myInputStream.setBufferTime(totalBuffer);
myInputStream.play(videoToLoad);
myInputStream.onStatus = function(infoObject) {
if (infoObject.code == "NetStream.Play.Start" || infoObject.code == "NetStream.Buffer.Empty") {
if (myInputStream.time<endtime) {
buffer_mc._visible = 1;
isBuffering = 1;
} else if (myInputStream.time>=endtime) {
_root.play();
}
} else if (infoObject.code == "NetStream.Buffer.Full") {
buffer_mc._visible = 0;
isBuffering = 0;
}
};
}
function bufferStatus() {
if (isBuffering) {
currentBuffer = myInputStream.bufferLength;
bufferPercent = currentBuffer/totalBuffer;
if (bufferPercent>1) {
bufferPercent=1, buffer_mc._visible=0;
}
buffer_mc.bar_mc._xscale = bufferPercent*100;
trace(bufferPercent);
}
}
_root.navBar.pause_btn.onRelease = function() {
pauseMovie();
};
_root.navBar.play_btn.onRelease = function() {
playMovie();
};
function pauseMovie() {
myInputStream.pause(true);
}
function playMovie() {
myInputStream.pause(false);
}
thanks!
- corey