I have a flv in my netstream. Somehow I cannot show the duration correctly. I have read forums and tried their ways, still no luck.
this part is in my constructor --------
//load video
var connection:NetConnection = new NetConnection();
connection.connect(null);
stream = new NetStream(connection);
stream.play(“video.flv”);
video = new Video();
video.attachNetStream(stream);
addChild(video);
//caculate video duration and initial cuepoint event
//handle function
var client:Object = new Object();
client.onMetaData = onMetaData;
client.onCuePoint = onCuePoint;
stream.client = client;
//create playback time info.
playbackTime = new TextField();
playbackTime.width = 50;
playbackTime.height = 20;
this.addEventListener(Event.ENTER_FRAME, handleEnterFrame);
then the functions
private function onMetaData(data:Object){
duration = data.duration;
trace(duration);
//resize video, video.width may not equial to video.videoWidth
video.width = video.videoWidth;
video.height = video.videoHeight;
//setup playtime info.
setPlaybackTime();
//setup subtitle
setSubtitle();
}
/*
* keep checking the playback time
*/
private function handleEnterFrame(event:Event):void {
playbackTime.text = Math.round(stream.time) + " / " + Math.round(duration);
trace(stream.time);
}
my duration time keeps showing 10. the elapsed time is ok.
Can someone help?
Thanks