0 Replies Latest reply on Jul 28, 2011 3:07 PM by slamorsi

    Complete event not fired

    slamorsi Level 1

      Hi,

       

      I'm wondering if this is a bug or intended or I'm just doing something wrong. I have a case where I need a few serial elements each containing a video and a duration element to be nested within a parallelElement. One problem is that the complete event is not fired at the end of playback when the duration elements are present whether before or after the video. It also works fine if the serial element is played directly rather than nested within a parallel. Here's some sample code, using 1.6 sprint5 (output below the code):

      <?xml version="1.0" encoding="utf-8"?>

      <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"

         xmlns:s="library://ns.adobe.com/flex/spark"

         xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600" xmlns:samples="org.osmf.samples.*" initialize="application1_initializeHandler(event)">

      <fx:Script>

      <![CDATA[

      import mx.events.FlexEvent;

       

      import org.osmf.containers.MediaContainer;

      import org.osmf.elements.DurationElement;

      import org.osmf.elements.LightweightVideoElement;

      import org.osmf.elements.ParallelElement;

      import org.osmf.elements.SerialElement;

      import org.osmf.events.LoadEvent;

      import org.osmf.events.MediaElementEvent;

      import org.osmf.events.MediaPlayerStateChangeEvent;

      import org.osmf.events.TimeEvent;

      import org.osmf.media.MediaPlayer;

      import org.osmf.net.DynamicStreamingItem;

      import org.osmf.net.DynamicStreamingResource;

      import org.osmf.traits.LoadState;

      import org.osmf.traits.LoadTrait;

      import org.osmf.traits.MediaTraitType;

      private var player:MediaPlayer;

      private var video:LightweightVideoElement;

       

      private var pe:ParallelElement = new ParallelElement;

      private var subpe:ParallelElement = new ParallelElement;

      private var de:DurationElement = new DurationElement(1);

      private var se:SerialElement = new SerialElement;

      private var dr:DynamicStreamingResource = new DynamicStreamingResource("rtmp://cp67126.edgefcs.net/ondemand");

       

      protected function application1_initializeHandler(event:FlexEvent):void

      {

      container.container = new MediaContainer;

      player = new MediaPlayer;

      video = new LightweightVideoElement;

      //player.bufferTime = 8;

      //player.loop = true;

      player.autoDynamicStreamSwitch = true;

      player.autoRewind = true;

      dr.streamItems = Vector.<DynamicStreamingItem>(

      [     new DynamicStreamingItem("mp4:mediapm/ovp/content/demo/video/elephants_dream/elephants_dream_ 768x428_24.0fps_408kbps.mp4", 408, 768, 428)

      , new DynamicStreamingItem("mp4:mediapm/ovp/content/demo/video/elephants_dream/elephants_dream_ 768x428_24.0fps_608kbps.mp4", 608, 768, 428)

      , new DynamicStreamingItem("mp4:mediapm/ovp/content/demo/video/elephants_dream/elephants_dream_ 1024x522_24.0fps_908kbps.mp4", 908, 1024, 522)

      , new DynamicStreamingItem("mp4:mediapm/ovp/content/demo/video/elephants_dream/elephants_dream_ 1024x522_24.0fps_1308kbps.mp4", 1308, 1024, 522)

      , new DynamicStreamingItem("mp4:mediapm/ovp/content/demo/video/elephants_dream/elephants_dream_ 1280x720_24.0fps_1708kbps.mp4", 1708, 1280, 720)

      ]);

      dr.clipStartTime = 0;

      dr.clipEndTime = 5;

       

      video.addEventListener(MediaElementEvent.TRAIT_ADD,traitAdded);

      video.resource = dr;

       

      }

       

      private function initPlayer():void{

      player.addEventListener(MediaPlayerStateChangeEvent.MEDIA_PLAYER_STATE_CHANGE,playerStateC hange);

      player.addEventListener(TimeEvent.COMPLETE,completeEvent);

      player.addEventListener(TimeEvent.CURRENT_TIME_CHANGE,timeChange);

       

      se.addChild(de);

      se.addChild(video);

      //subpe.addChild(se);

      pe.addChild(se);

      container.container.addMediaElement(pe);

      player.media = pe;

      }

       

       

      private function playerStateChange(e:MediaPlayerStateChangeEvent):void{

      trace('player state change: ' + e.state);

      }

       

      private function completeEvent(e:TimeEvent):void{

      trace('player time complete');

      }

       

      private function timeChange(e:TimeEvent):void{

      trace('time change: ' + e.time);

      }

       

      private function traitAdded(e:MediaElementEvent):void{

      trace("trait added: " + e.traitType);

      switch(e.traitType){

      case MediaTraitType.LOAD :

      var loader:LoadTrait = LoadTrait(e.target.getTrait(e.traitType));

      if(loader.loadState == LoadState.READY){

      trace("loader ready1");

      initPlayer();

      }else{

      //once all elements are pre-loaded, start playback

      loader.addEventListener(LoadEvent.LOAD_STATE_CHANGE,function(e:LoadEvent):void{

       

      if(e.loadState == LoadState.LOAD_ERROR){

      trace("Pre load error");

      }else if(e.loadState == LoadState.READY){

      e.target.removeEventListener(LoadEvent.LOAD_STATE_CHANGE,arguments.callee);

      initPlayer();

      return

      }

      });

      //make sure its not already loading or it'll throw an error

      if(loader.loadState != LoadState.LOADING){

       

      trace('loader preload: ' + loader.loadState);

      loader.load();

      trace('loader postload: ' + loader.loadState);

      }

      }

      break;

      }

      }

       

      ]]>

      </fx:Script>

       

      <fx:Declarations>

      <!-- Place non-visual elements (e.g., services, value objects) here -->

      </fx:Declarations>

      <samples:MediaContainerUIComponent id="container" height="100%" width="100%"/>

      </s:Application>

      And the output:
      trait added: load
      loader preload: uninitialized
      Thu Jul 28 2011 03:06:17 PM [INFO] [org.osmf.net.NetNegotiator] Attempting connection to rtmp://cp67126.edgefcs.net:1935/ondemand
      loader postload: loading
      Thu Jul 28 2011 03:06:17 PM [DEBUG] [org.osmf.layout.LayoutRendererBase] ON EXIT FRAME: BEGIN
      Thu Jul 28 2011 03:06:17 PM [DEBUG] [org.osmf.layout.LayoutRendererBase] VALIDATING LAYOUT
      Thu Jul 28 2011 03:06:17 PM [DEBUG] [org.osmf.layout.LayoutRendererBase] layout dimensions before measurement (NaN, NaN)
      Thu Jul 28 2011 03:06:17 PM [DEBUG] [org.osmf.layout.LayoutRendererBase] layout dimensions after measurement (0, 0)
      Thu Jul 28 2011 03:06:17 PM [DEBUG] [org.osmf.layout.LayoutRendererBase] LAYOUT VALIDATED
      Thu Jul 28 2011 03:06:17 PM [DEBUG] [org.osmf.layout.LayoutRendererBase] ON EXIT FRAME: END
      Thu Jul 28 2011 03:06:17 PM [DEBUG] [org.osmf.layout.LayoutRendererBase] ON EXIT FRAME: BEGIN
      Thu Jul 28 2011 03:06:17 PM [DEBUG] [org.osmf.layout.LayoutRendererBase] VALIDATING LAYOUT
      Thu Jul 28 2011 03:06:17 PM [DEBUG] [org.osmf.layout.LayoutRendererBase] layout dimensions before measurement (0, 0)
      Thu Jul 28 2011 03:06:17 PM [DEBUG] [org.osmf.layout.LayoutRendererBase] layout dimensions after measurement (955, 600)
      Thu Jul 28 2011 03:06:17 PM [DEBUG] [org.osmf.layout.LayoutRendererBase] LAYOUT VALIDATED
      Thu Jul 28 2011 03:06:17 PM [DEBUG] [org.osmf.layout.LayoutRendererBase] ON EXIT FRAME: END
      Thu Jul 28 2011 03:06:17 PM [INFO] [org.osmf.net.NetNegotiator] Attempting connection to rtmp://cp67126.edgefcs.net:443/ondemand
      Thu Jul 28 2011 03:06:17 PM [INFO] [org.osmf.net.NetNegotiator] Attempting connection to rtmp://cp67126.edgefcs.net:80/ondemand
      Thu Jul 28 2011 03:06:17 PM [INFO] [org.osmf.net.NetNegotiator] FMS Version: 3,5,6,6003
      Thu Jul 28 2011 03:06:17 PM [INFO] [org.osmf.net.NetConnectionFactory] NetConnection established with: rtmp://cp67126.edgefcs.net:443/ondemand
      trait added: audio
      trait added: buffer
      trait added: time
      trait added: displayObject
      trait added: play
      player state change: ready
      player state change: playing
      Thu Jul 28 2011 03:06:17 PM [DEBUG] [org.osmf.layout.LayoutRendererBase] ON EXIT FRAME: BEGIN
      Thu Jul 28 2011 03:06:17 PM [DEBUG] [org.osmf.layout.LayoutRendererBase] VALIDATING LAYOUT
      Thu Jul 28 2011 03:06:17 PM [DEBUG] [org.osmf.layout.LayoutRendererBase] layout dimensions before measurement (955, 600)
      Thu Jul 28 2011 03:06:17 PM [DEBUG] [org.osmf.layout.LayoutRendererBase] layout dimensions after measurement (955, 600)
      Thu Jul 28 2011 03:06:17 PM [DEBUG] [org.osmf.layout.LayoutRenderer] dimensions: (x=0, y=0, w=955, h=600) available: (955, 600), media: (NaN,NaN) target (null)
      Thu Jul 28 2011 03:06:17 PM [DEBUG] [org.osmf.layout.LayoutRendererBase] LAYOUT VALIDATED
      Thu Jul 28 2011 03:06:17 PM [DEBUG] [org.osmf.layout.LayoutRendererBase] ON EXIT FRAME: END
      time change: 0.266
      time change: 0.556
      time change: 0.806
      time change: 0
      time change: 1
      Thu Jul 28 2011 03:06:18 PM [DEBUG] [org.osmf.layout.LayoutRendererBase] ON EXIT FRAME: BEGIN
      Thu Jul 28 2011 03:06:18 PM [DEBUG] [org.osmf.layout.LayoutRendererBase] VALIDATING LAYOUT
      Thu Jul 28 2011 03:06:18 PM [DEBUG] [org.osmf.layout.LayoutRendererBase] layout dimensions before measurement (NaN, NaN)
      Thu Jul 28 2011 03:06:18 PM [DEBUG] [org.osmf.layout.LayoutRenderer] dimensions: (x=0, y=0, w=NaN, h=NaN) available: (NaN, NaN), media: (NaN,NaN) target ([object VideoSurface])
      Thu Jul 28 2011 03:06:18 PM [DEBUG] [org.osmf.layout.LayoutRendererBase] layout dimensions after measurement (0, 0)
      Thu Jul 28 2011 03:06:18 PM [DEBUG] [org.osmf.layout.LayoutRenderer] dimensions: (x=0, y=0, w=0, h=0) available: (0, 0), media: (NaN,NaN) target ([object VideoSurface])
      Thu Jul 28 2011 03:06:18 PM [DEBUG] [org.osmf.layout.LayoutRendererBase] LAYOUT VALIDATED
      Thu Jul 28 2011 03:06:18 PM [DEBUG] [org.osmf.layout.LayoutRendererBase] VALIDATING LAYOUT
      Thu Jul 28 2011 03:06:18 PM [DEBUG] [org.osmf.layout.LayoutRendererBase] layout dimensions before measurement (955, 600)
      Thu Jul 28 2011 03:06:18 PM [INFO] [org.osmf.media.videoClasses.VideoSurface] switchRenderer. currentVideoRenderer = null; the new renderer = [object Video]
      Thu Jul 28 2011 03:06:18 PM [DEBUG] [org.osmf.layout.LayoutRenderer] dimensions: (x=0, y=0, w=NaN, h=NaN) available: (NaN, NaN), media: (NaN,NaN) target ([object VideoSurface])
      Thu Jul 28 2011 03:06:18 PM [DEBUG] [org.osmf.layout.LayoutRenderer] dimensions: (x=0, y=0, w=NaN, h=NaN) available: (NaN, NaN), media: (0,0) target ([object LayoutTargetSprite])
      Thu Jul 28 2011 03:06:18 PM [DEBUG] [org.osmf.layout.LayoutRendererBase] layout dimensions after measurement (955, 600)
      Thu Jul 28 2011 03:06:18 PM [DEBUG] [org.osmf.layout.LayoutRenderer] dimensions: (x=0, y=0, w=955, h=600) available: (955, 600), media: (0,0) target ([object LayoutTargetSprite])
      Thu Jul 28 2011 03:06:18 PM [DEBUG] [org.osmf.layout.LayoutRenderer] dimensions: (x=0, y=0, w=955, h=600) available: (955, 600), media: (0,0) target ([object LayoutTargetSprite])
      Thu Jul 28 2011 03:06:18 PM [DEBUG] [org.osmf.layout.LayoutRenderer] dimensions: (x=0, y=0, w=955, h=600) available: (955, 600), media: (NaN,NaN) target ([object VideoSurface])
      Thu Jul 28 2011 03:06:18 PM [DEBUG] [org.osmf.layout.LayoutRendererBase] LAYOUT VALIDATED
      Thu Jul 28 2011 03:06:18 PM [DEBUG] [org.osmf.layout.LayoutRendererBase] ON EXIT FRAME: END
      Thu Jul 28 2011 03:06:18 PM [INFO] [org.osmf.net.NetStreamLoadTrait] NetStream.Play.Reset
      Thu Jul 28 2011 03:06:18 PM [INFO] [org.osmf.net.NetLoader] Stream reconnect: onNetStatus: NetStream.Play.Reset
      Thu Jul 28 2011 03:06:18 PM [INFO] [org.osmf.net.NetStreamLoadTrait] NetStream.Play.Start
      Thu Jul 28 2011 03:06:18 PM [INFO] [org.osmf.net.NetLoader] Stream reconnect: onNetStatus: NetStream.Play.Start
      player state change: buffering
      time change: 1
      Thu Jul 28 2011 03:06:19 PM [INFO] [org.osmf.net.NetStreamLoadTrait] NetStream.Buffer.Full
      Thu Jul 28 2011 03:06:19 PM [INFO] [org.osmf.net.NetLoader] Stream reconnect: onNetStatus: NetStream.Buffer.Full
      player state change: playing
      trait added: seek
      Thu Jul 28 2011 03:06:19 PM [DEBUG] [org.osmf.layout.LayoutRendererBase] ON EXIT FRAME: BEGIN
      Thu Jul 28 2011 03:06:19 PM [DEBUG] [org.osmf.layout.LayoutRendererBase] VALIDATING LAYOUT
      Thu Jul 28 2011 03:06:19 PM [DEBUG] [org.osmf.layout.LayoutRendererBase] layout dimensions before measurement (0, 0)
      Thu Jul 28 2011 03:06:19 PM [DEBUG] [org.osmf.layout.LayoutRenderer] dimensions: (x=0, y=0, w=NaN, h=NaN) available: (NaN, NaN), media: (768,428) target ([object VideoSurface])
      Thu Jul 28 2011 03:06:19 PM [DEBUG] [org.osmf.layout.LayoutRendererBase] layout dimensions after measurement (768, 428)
      Thu Jul 28 2011 03:06:19 PM [DEBUG] [org.osmf.layout.LayoutRenderer] dimensions: (x=0, y=0, w=768, h=428) available: (768, 428), media: (768,428) target ([object VideoSurface])
      Thu Jul 28 2011 03:06:19 PM [DEBUG] [org.osmf.layout.LayoutRendererBase] LAYOUT VALIDATED
      Thu Jul 28 2011 03:06:19 PM [DEBUG] [org.osmf.layout.LayoutRendererBase] VALIDATING LAYOUT
      Thu Jul 28 2011 03:06:19 PM [DEBUG] [org.osmf.layout.LayoutRendererBase] layout dimensions before measurement (955, 600)
      Thu Jul 28 2011 03:06:19 PM [DEBUG] [org.osmf.layout.LayoutRenderer] dimensions: (x=0, y=0, w=NaN, h=NaN) available: (NaN, NaN), media: (768,428) target ([object VideoSurface])
      Thu Jul 28 2011 03:06:19 PM [DEBUG] [org.osmf.layout.LayoutRenderer] dimensions: (x=0, y=0, w=NaN, h=NaN) available: (NaN, NaN), media: (768,428) target ([object LayoutTargetSprite])
      Thu Jul 28 2011 03:06:19 PM [DEBUG] [org.osmf.layout.LayoutRendererBase] layout dimensions after measurement (955, 600)
      Thu Jul 28 2011 03:06:19 PM [DEBUG] [org.osmf.layout.LayoutRenderer] dimensions: (x=0, y=34, w=955, h=532) available: (955, 600), media: (768,428) target ([object LayoutTargetSprite])
      Thu Jul 28 2011 03:06:19 PM [DEBUG] [org.osmf.layout.LayoutRenderer] dimensions: (x=0, y=0, w=955, h=532) available: (955, 532), media: (768,428) target ([object LayoutTargetSprite])
      Thu Jul 28 2011 03:06:19 PM [DEBUG] [org.osmf.layout.LayoutRenderer] dimensions: (x=0, y=0, w=955, h=532) available: (955, 532), media: (768,428) target ([object VideoSurface])
      Thu Jul 28 2011 03:06:19 PM [DEBUG] [org.osmf.layout.LayoutRendererBase] LAYOUT VALIDATED
      Thu Jul 28 2011 03:06:19 PM [DEBUG] [org.osmf.layout.LayoutRendererBase] ON EXIT FRAME: END
      time change: 1.208
      time change: 1.405
      time change: 1.6400000000000001
      time change: 1.875
      time change: 2.152
      time change: 2.387
      time change: 2.625
      time change: 2.899
      time change: 3.133
      time change: 3.411
      time change: 3.645
      Thu Jul 28 2011 03:06:21 PM [INFO] [org.osmf.net.NetStreamLoadTrait] NetStream.Play.Stop
      Thu Jul 28 2011 03:06:21 PM [INFO] [org.osmf.net.NetLoader] Stream reconnect: onNetStatus: NetStream.Play.Stop
      Thu Jul 28 2011 03:06:21 PM [INFO] [org.osmf.net.NetStreamLoadTrait] NetStream.Buffer.Flush
      Thu Jul 28 2011 03:06:21 PM [INFO] [org.osmf.net.NetLoader] Stream reconnect: onNetStatus: NetStream.Buffer.Flush
      time change: 3.875
      time change: 4.157
      time change: 4.375
      time change: 4.648
      time change: 4.947
      time change: 5.167
      time change: 5.437
      time change: 5.672
      time change: 5.949
      player state change: buffering
      time change: 0
      Thu Jul 28 2011 03:06:24 PM [INFO] [org.osmf.media.videoClasses.VideoSurface] switchRenderer. currentVideoRenderer = [object Video]; the new renderer = null
      Thu Jul 28 2011 03:06:24 PM [INFO] [org.osmf.net.NetStreamLoadTrait] NetStream.Pause.Notify
      Thu Jul 28 2011 03:06:24 PM [INFO] [org.osmf.net.NetLoader] Stream reconnect: onNetStatus: NetStream.Pause.Notify
      Thu Jul 28 2011 03:06:24 PM [DEBUG] [org.osmf.layout.LayoutRendererBase] ON EXIT FRAME: BEGIN
      Thu Jul 28 2011 03:06:24 PM [DEBUG] [org.osmf.layout.LayoutRendererBase] VALIDATING LAYOUT
      Thu Jul 28 2011 03:06:24 PM [DEBUG] [org.osmf.layout.LayoutRendererBase] layout dimensions before measurement (955, 600)
      Thu Jul 28 2011 03:06:24 PM [DEBUG] [org.osmf.layout.LayoutRendererBase] layout dimensions after measurement (955, 600)
      Thu Jul 28 2011 03:06:24 PM [DEBUG] [org.osmf.layout.LayoutRenderer] dimensions: (x=0, y=0, w=955, h=600) available: (955, 600), media: (NaN,NaN) target (null)
      Thu Jul 28 2011 03:06:24 PM [DEBUG] [org.osmf.layout.LayoutRendererBase] LAYOUT VALIDATED
      Thu Jul 28 2011 03:06:24 PM [DEBUG] [org.osmf.layout.LayoutRendererBase] VALIDATING LAYOUT
      Thu Jul 28 2011 03:06:24 PM [DEBUG] [org.osmf.layout.LayoutRendererBase] layout dimensions before measurement (768, 428)
      Thu Jul 28 2011 03:06:24 PM [DEBUG] [org.osmf.layout.LayoutRenderer] dimensions: (x=0, y=0, w=NaN, h=NaN) available: (NaN, NaN), media: (NaN,NaN) target (null)
      Thu Jul 28 2011 03:06:24 PM [DEBUG] [org.osmf.layout.LayoutRendererBase] layout dimensions after measurement (0, 0)
      Thu Jul 28 2011 03:06:24 PM [DEBUG] [org.osmf.layout.LayoutRenderer] dimensions: (x=0, y=0, w=0, h=0) available: (0, 0), media: (NaN,NaN) target (null)
      Thu Jul 28 2011 03:06:24 PM [DEBUG] [org.osmf.layout.LayoutRendererBase] LAYOUT VALIDATED
      Thu Jul 28 2011 03:06:24 PM [DEBUG] [org.osmf.layout.LayoutRendererBase] ON EXIT FRAME: END
      Thu Jul 28 2011 03:06:24 PM [INFO] [org.osmf.net.NetStreamLoadTrait] NetStream.Seek.Notify
      Thu Jul 28 2011 03:06:24 PM [INFO] [org.osmf.net.NetLoader] Stream reconnect: onNetStatus: NetStream.Seek.Notify
      Thu Jul 28 2011 03:06:24 PM [INFO] [org.osmf.net.NetStreamLoadTrait] NetStream.Play.Start
      Thu Jul 28 2011 03:06:24 PM [INFO] [org.osmf.net.NetLoader] Stream reconnect: onNetStatus: NetStream.Play.Start
      player state change: ready
      Thu Jul 28 2011 03:06:24 PM [INFO] [org.osmf.net.NetStreamLoadTrait] NetStream.Buffer.Flush
      Thu Jul 28 2011 03:06:24 PM [INFO] [org.osmf.net.NetLoader] Stream reconnect: onNetStatus: NetStream.Buffer.Flush
      time change: 0