0 Replies Latest reply on Jun 3, 2015 8:39 AM by amian84

    ParallelElement into Android devices

    amian84 Level 1

      Hi, I'm trying play a video streaming with two channels simultaneously. For this I use a ParallelElement  and a MediaPlayer to play it. When the video ends, the Complete event doesn't dispatch then I cant know when finish my video. This is a code example:

       

       

      public class MediaPlayerExample extends Sprite

      {

         private var mediaPlayer:MediaPlayer;

         private var m_factory : MediaFactory = null;

       

         public function MediaPlayerExample()

        {

         super();

         m_factory = new DefaultMediaFactory;

         var _video:String = "http://url_to_video/video.mp4";

         var _audio:String = "http://url_to_audio/audio.mp3";

         var _videoElement : VideoElement = createVideoElement(_video);

         var _audioElement : AudioElement = createAudioElement(_audio);

         var _mediaElement : MediaElement = createParallel([  _audioElement,_videoElement  ]);

       

         mediaPlayer = new MediaPlayer();

       

       

         mediaPlayer.volume = .5;

         mediaPlayer.loop = true;

         mediaPlayer.addEventListener(TimeEvent.CURRENT_TIME_CHANGE, onTimeUpdated);

         mediaPlayer.addEventListener(TimeEvent.DURATION_CHANGE, onTimeUpdated);

         mediaPlayer.addEventListener(TimeEvent.COMPLETE, onComplete);

         mediaPlayer.addEventListener(MediaPlayerStateChangeEvent.MEDIA_PLAYER_STATE_CHANGE, onPlayerStateChange);

         mediaPlayer.autoPlay = true;

         mediaPlayer.media = _mediaElement;

       

        }

       

       

         public function createElement (_url : String) : MediaElement

        {

         var _urlResource : URLResource = new URLResource(_url);

         var _element : MediaElement = m_factory.createMediaElement(_urlResource);

       

         return _element;

        }

         public function createVideoElement (_url : String) : VideoElement

        {

         var _urlResource : URLResource = new URLResource(_url);

       

         var _element:VideoElement = VideoElement(createElement(_url));

         return _element;

        }

       

         public function createAudioElement (_url : String) : AudioElement

        {

         var _urlResource : URLResource = new URLResource(_url);

         var _element : AudioElement = AudioElement(createElement(_url));

         return _element;

        }

       

         public function createParallel (_elementsArray : Array) : ParallelElement

        {

         var _parallelElement : ParallelElement = new ParallelElement();

         for each (var _item : * in _elementsArray)

         if (_item) _parallelElement.addChild(_item);

         return _parallelElement;

       

        }

        private function onPlayerStateChange (e : MediaPlayerStateChangeEvent) : void
        {

           trace("onPlayerStateChange -> " + e.state +" - bufferTime "+ mediaPlayer.bufferTime );

        }

       

        private function onTimeUpdated(event:TimeEvent):void
        {

           trace('time: ' + mediaPlayer.currentTime + ' duration: ' + mediaPlayer.duration);

        }

       

         private function onComplete(event:TimeEvent):void
         {

         trace("FINISH");

        }

       

      }

      Does anyone have any ideas to work?