totalTime and MetadataReceived from VideoDisplay object in Flex

Thomas Viktil

Interesting (and more than a bit annoying) observation; neither the property totalTime or the event MetadataEvent.METADATA_RECEIVED will trigger unless the buffer is full.

I just discovered this as I tried to dynamically set the bufferTime to be 30% of the total playtime (I calculate the bufferTime using totalBytes and bytesLoaded). But as I traced values like totalTime, I noticed it would stay at -1 until the video started playing (in other words; the buffer was full). Just for the sake of curiosity I set up an eventlistener listening for the duration property of the MetadataReceived event object. Interesting enough it wouldn’t trigger until the buffer was full.

It has been filed as a bug at Adobe’s Flex Bug and Issues Management System.

Possible workaround:

  1. set bufferTime to 0 at initialization (this would hopefully trigger the READY event (or MetadataReceived if you prefer)
  2. catch the totalTime value
  3. pause/stop the video
  4. increase bufferTime (or skip number 3 and go directly to number 4. It might work?)

Technorati Tags: , , , , ,


One Response to “totalTime and MetadataReceived from VideoDisplay object in Flex”

  • chiu Says:

    thanks!
    i think you have saved my day!
    was so annoyed why the Metadata_RECEIVED event is not firing sometimes.

Leave a Reply