1 Reply Latest reply on Jan 25, 2010 9:46 AM by bringrags

    Problems with stop AudioElement added in SerialElement

    ZAGU

      Hi.

       

      I am using OSMF Sprint 8 Release.

       

      Problem is that. If you add AudioElement into SerialElement for playing one and then try calling stop() method then playback stops but currentTime property (MediaPlayer property) doesn't jump to 0 sec. Then if you try call play() method (restart) then playing begins but CURRENT_TIME_CHANGE event doesn't fire. Also if play this SerialElement and wait for one stop then audio stops playing but currentTime property doesn't jump to 0 sec and if restart playing CURRENT_TIME_CHANGE event doesn't fire.

       

      As opposite behavior is that if play AudioElement wihout adding one into SerialElementall all working good in all cases: currentTime jump to 0 sec and CURRENT_TIME_CHANGE event fires always.

       

      Is it bug ? Please check.

       

      Please look at code below and in attached Main.as.

       

      package
      {
         ....

          public class Main extends Sprite
          {
             ...
             
              public function Main()
              {           
                  var mediaPlayerSprite:MediaPlayerSprite = new MediaPlayerSprite();
                  addChild(mediaPlayerSprite);
                  mediaPlayer = mediaPlayerSprite.mediaPlayer;
                  ...
                  mediaPlayer.addEventListener(TimeEvent.CURRENT_TIME_CHANGE, onCurrentTimeChange);
                  mediaPlayer.addEventListener(PlayEvent.PLAY_STATE_CHANGE, onPlayStateChange);
                  ...
                  //mediaPlayerSprite.element = serialMedia;
                  mediaPlayerSprite.element = audioElement;
              }
             
              private function onPlayClick(event : MouseEvent) : void
              {
                  mediaPlayer.play();
              }

       

              private function onStopClick(event : MouseEvent) : void
              {
                  mediaPlayer.stop();
              }

       

              public function get audioElement() : AudioElement
              {
                  var AUDIO_URL : String = 'tin.mp3';
                  var audioLoader: SoundLoader = new SoundLoader();
                    var audio : AudioElement = new AudioElement( audioLoader,new URLResource(new URL(AUDIO_URL)));
                   
                    return audio;
              }
             
              public function get serialMedia() : SerialElement
              {
                  var serialMedia : SerialElement = new SerialElement();   
                  serialMedia.addChild(audioElement);
                 
                  return serialMedia;
              }


              ...


              private function onCurrentTimeChange(event : TimeEvent) : void
              {
                  trace(mediaPlayer.currentTime,mediaPlayer.duration);
              }
             
              private function onPlayStateChange(event : PlayEvent) : void
              {
                  trace(event.playState);
              }
          }
      }

       

      Thank you in advance

      Alexandr.