Results 1 to 2 of 2

Thread: Problem displaying duration time Netstream

  1. #1

    Problem displaying duration time Netstream

    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

  2. #2
    Quote Originally Posted by TheMagicMan View Post
    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
    try this
    this.createEmptyMovieClip("vFrame",this.getNextHig hestDepth());
    vFrame.onEnterFrame = videoStatus;
    var date = new Date(2008, 0, 1, 0, 0, 0, 0);
    var amountLoaded:Number;
    var duration:Number;

    stream["onMetaData"] = function(obj) {
    duration = obj.duration;
    }
    function format_minute_time(t) {
    if (t == undefined) {
    return ("0:00");
    }
    var seconden = String(Math.floor(t % 60));
    if (seconden.length == 1){
    seconden = "0" + seconden;
    }
    var minuten = String(Math.floor(t / 60));
    if (minuten.length == 1){
    minuten = "0" + minuten;
    }
    return (minuten + ":" + seconden);
    }

    function videoStatus() {
    timer.speeltijd = format_minute_time(duration);
    date.setHours(0, 0, ns.time, 0);
    timer.tijd.text = substring(date.getMinutes() + 100, 2, 2) + ":" + substring(date.getSeconds() + 100, 2, 2);
    amountLoaded = stream.bytesLoaded / stream.bytesTotal;
    loader.loadbar._width = amountLoaded * 208.9;
    loader.scrub._x = stream.time / duration * 208.9;
    loader.speeltijd._xscale = stream.time / duration * 100;
    }
    Rombout Versluijs
    Curacao, Netherland Antilles

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

Home About kirupa.com Meet the Moderators Advertise

 Link to Us

 Credits

Copyright 1999 - 2012