0 Replies Latest reply on Feb 3, 2009 8:53 AM by sumone4life

    H.264 MP4 Scrubber Problem

    sumone4life
      I am trying to make a custom H.264 video player. I can get the video to load and play and all that but i cannot get the scrubber bar to work. I tried using the onMetaData function but i dont think it is even running because i get no trace.

      Is there any way to get the total duration of the MP4 video?

      [code]
      //Video Loading Controls

      var fileName:String = "test";

      var nc:NetConnection = new NetConnection();
      var ns:NetStream;

      nc.onStatus = function(info){
      trace(info.code);
      if(info.code == "NetConnection.Connect.Success"){
      playVideo();
      }
      }

      function playVideo(){
      ns = new NetStream(nc);
      videoObject.attachVideo(ns);

      ns.setBufferTime(1);
      ns.play("MP4:" + fileName + ".f4v");

      controlBar_mc.playPause_mc.got oAndStop("play");
      }

      //connects the stream
      nc.connect("rtmp://137.99.136.55 /sumone4life/videos");



      //Media Controls

      //Play Pause
      controlBar_mc.playPause_mc.onRollOver = function()
      {
      if(this._currentframe == 1)this.gotoAndStop("pauseOver");
      else this.gotoAndStop("playOver");
      }

      controlBar_mc.playPause_mc.onRollOut = controlBar_mc.playPause_mc.onReleaseOutside = function()
      {
      if(this._currentframe == 10)this.gotoAndStop("pause");
      else this.gotoAndStop("play");
      }

      controlBar_mc.playPause_mc.onRelease = function(){
      if(this._currentframe == 10)
      {
      this.gotoAndStop('playOver');
      ns.pause();
      }
      else
      {
      this.gotoAndStop('pauseOver');
      ns.pause();
      }
      }

      //Rewind
      controlBar_mc.rewindButton.onRelease = function(){
      ns.seek(0);
      }


      //loadbar controls
      var videoInterval = setInterval(videoStatus, 100);
      var amountLoaded:Number;
      var videoDuration:Number;

      ns.onMetaData = function(obj){
      trace("We are in metadata");
      videoDuration = obj.duration;
      }

      function videoStatus(){
      amountLoaded = ns.bytesLoaded / ns.bytesTotal;
      controlBar_mc.loader_mc.loadBa r_mc._width = amountLoaded * 502;
      trace("ns.time: " + ns.time + " videoDuration: " + videoDuration);
      controlBar_mc.loader_mc.scrub_ mc._x = ns.time / videoDuration * 502;
      }
      [/code]

      P.S. I never get the trace("we are in metadata"); so i figure that that part of program is not even running. I have also tried ns["onMetaData"].

      I have Flash CS4 and Media Server 3.0 using AS2 if that makes any difference.