1 Reply Latest reply on Jun 14, 2009 8:07 AM by kglad

    help with flvplayback component

    PurpleArts

      hi,

       

      i managed to get the videeo length and display the total time and playtime of the video..

       

      i could see that the lenght is correct but the i can't see the video and the lenght is updating as the video progresses but i can't view the video..

       

      please help me.. thanks..


      note that , the location of the video i'm getting is retrieve from an external variable passed by js.

       

       

       

      import mx.controls.SimpleButton;
      import mx.utils.Delegate;
      import com.greensock.TweenLite;
      import com.robertpenner.easing.Quad;
      import mx.video.FLVPlayback;
      import flash.external.ExternalInterface;
      import flash.events.Event;

       


      var _totalText:TextField;
      var _progressText:TextField;
      var _duration:Number;
      var _isPlaying:Boolean;
      var _flvInterval:Number;
      var _totalInterval:Number;
      var _movieTimeBG:MovieClip;
      var _percentageTracked:Number;
      //FLVComponent to load the skin
      var _flvPlayBack:FLVPlayback;
      //Instance of NULL as object
      var objectInstance:Object = null;

       

      //Instance of the Podcast Button, setting it to invisible
      onload()
      {_podcastDownload._visible = false;
      }

       

      /*ExternalInterface.addCallback("sendTextToFlash",objectInstance,getTextFromJavaScript);
      //Function to verify that the url has a value
      function getTextFromJavaScript(str:Object):Void

          received_ti.text = "From JavaScript: " + str;
          label_received.text= str;
      }//end function*/

       

      //Class that the javascript is calling
      ExternalInterface.addCallback("sendVideoURLToFlash",objectInstance,getVidURLFromJS);
      function getVidURLFromJS(VidStr:String):Void
          {
              var vidURL:String = VidStr;
              label_received.text = "The path of the video media that was passed to js was: " + vidURL;
              _flvPlayBack.contentPath = vidURL;
              //_flvPlayBack.contentPath = _parent.movieLocation;
              _flvPlayBack.autoSize = false;
              //_flvPlayBack.maintainAspectRatio = false;
         
              _flvInterval = setInterval(Delegate.create(this, updatePlayTime), 1000, _flvPlayBack);
              _totalInterval = setInterval(Delegate.create(this, setTotalTime), 1000, _flvPlayBack);
              //_flvPlayBack.play();
              //_flvPlayBack.load();
              _flvPlayBack.play();
             
              _isPlaying = true;
              setTotalTime(_flvPlayBack);
             
              trackMovieStarted();
              _percentageTracked = 0;
             
          }//End of Get Video URL from JS Function

       


      function setTotalTime(_flvPlayBack:FLVPlayback) {
          _progressText._y = _flvPlayBack.height+14;
          _totalText._y = _flvPlayBack.height + 14;
          _movieTimeBG._y = _flvPlayBack.height+22;
         
          if (_flvPlayBack.totalTime > 0) {
              clearInterval(_totalInterval);
              _duration = _flvPlayBack.totalTime;
              var dur_seconds:Number = _duration;
              var minutes_dspl = Math.floor(dur_seconds/60);
              var seconds_dspl = Math.floor(dur_seconds%60);
          if (minutes_dspl<10) {
              minutes_dspl = ("0"+minutes_dspl);
          }
          if (seconds_dspl<10) {
              seconds_dspl = ("0"+seconds_dspl);
          }
              _totalText.text = "/ " + minutes_dspl + ":" + seconds_dspl;
          }
      }

       


      function updatePlayTime(_flvPlayBack:FLVPlayback) {
          var ns_seconds:Number = _flvPlayBack.playheadTime;
          var minutes:Number = Math.floor(ns_seconds / 60);
          var seconds = Math.floor(ns_seconds%60);
          if (seconds<10) {
             seconds = "0"+seconds;
          }
          _progressText.text = minutes + ":" + seconds;
          checkReportTime(_flvPlayBack.playheadTime);
      }

       

      function checkReportTime(sec:Number):Void {
          var perc = Math.round((sec / _flvPlayBack.totalTime) * 100);

       

          switch(perc) {
              case 25:
              trackTime(25);
              break;
              case 50:
              trackTime(50);
              break;
              case 75:
              trackTime(75);
              break;
              case 100:
              trackTime(100);
              break;
          }
      }

       

       

       

       

      you can also refer to the attached file for reference..

      thanks so much..