1 Reply Latest reply on May 6, 2008 5:07 AM by Coteali

    Problem with streaming+timer

    Coteali
      So, I have a player
      when click on a song, a timer loads duration of song and starts descending to 0:00. I stream song from internet, so they need to first be streamed and then played, part by part. Problem is that during song is streaming (not playing) timer keeps going. How can I make that timer counts only when songs are playing

      codes:

      var name_of_song:Sound = new Sound();

      import mx.transitions.Tween;

      gumb1.onRelease = function() {

      counter(timer1,"00:03:40","no",false); <-- starts timer

      function counter(theTextField, time, sec, dir) {
      var t:Array = time.split(":");
      for (i in t) {
      t = Number(t);
      }
      var h:Number = t[0]*3600;
      var m:Number = t[1]*60;
      var s:Number = t[2];
      var total:Number = h+m+s;
      var sec:Number = (!sec || sec == "no") ? total : sec;
      var min:Number = total/60;
      var obj:Object = {};
      obj.rr = 0;
      var twn:Tween = (!dir || dir == false) ? new Tween(obj, "rr", None, min, 0, sec, true) : new Tween(obj, "rr", None, 0, min, sec, true);
      twn.onMotionChanged = function() {
      var _min = ((obj.rr/60-((obj.rr/60) >> 0))*60) >> 0;
      var _sec = ((obj.rr-((obj.rr) >> 0))*60) >> 0;

      if (_sec<10) {
      _sec = "0"+_sec;
      }
      if (_min<10) {
      _min = "0"+_min;
      }
      theTextField.text = _min+":"+_sec;
      };
      twn.onMotionFinished = function() {
      theTextField.onCounterFinished();
      };
      }

      stopAllSounds();

      name_of_song.loadSound(" http://www.fileden.com/files/2006/11/26/423543/B114-loq.mp3",true); <--stream
      }