Skip to main content
Inspiring
November 20, 2008
Question

NetStream.time Inconsistent

  • November 20, 2008
  • 1 reply
  • 657 views
Hello,

I am using the following code provided by Adobe to display the current time of a media stream

var connection_nc:NetConnection = new NetConnection();
connection_nc.connect(null);
var stream_ns:NetStream = new NetStream(connection_nc);
my_video.attachVideo(stream_ns);
stream_ns.play("video1.flv");
//
stream_ns.onStatus = function(infoObject:Object) {
statusCode_txt.text = infoObject.code;
};

this.createTextField("time_txt", this.getNextHighestDepth(), 10, 10, 100, 22);
time_txt.text = "LOADING";

var time_interval:Number = setInterval(checkTime, 500, stream_ns);
function checkTime(my_ns:NetStream) {
var ns_seconds:Number = my_ns.time;
var minutes:Number = Math.floor(ns_seconds/60);
var seconds = Math.floor(ns_seconds%60);
if (seconds<10) {
seconds = "0"+seconds;
}
time_txt.text = minutes+":"+seconds;
}


and it works great for the most part. However, sometimes when moving to a new stream in the application, the stream seems to get caught up. Ive traced the "time_txt" variable (minutes + seconds) receiving the following output below. And in the display in the application, it "blinks" matching output, in the interval that is set in the the number in the setInterval variable above (500).

it doesnt happen all the time. when i let the media play and advance itself, it seems to work ok. its when i "agitate" the streams -- moving between media streams quickly, advancing, going back, etc. when its working normally and i trace the text_txt variable, there are no zero stops inbetween the seconds in the output below.

If anyone has any suggestions i would appreciate it.

thanks!


0:0
0:0
0:0
0:0
0:1
0:0
0:0
0:0
0:1
0:0
0:0
0:0
0:2
0:0
0:0
0:0
0:3
0:0
0:0
0:0
0:3
0:0
0:0
0:0
0:4
0:0
0:0
0:0
0:4
0:0
0:0
0:0
0:5
0:0
0:0
0:0
0:5
0:0
0:0
0:0
0:6
0:0
0:0
0:0
0:6
0:0
0:0
0:0
0:7
    This topic has been closed for replies.

    1 reply

    November 20, 2008