A Flash Developer Resource Site

Results 1 to 10 of 10

Thread: FLVPlayback and metadata

  1. #1
    Junior Member
    Join Date
    Sep 2008
    Posts
    2

    FLVPlayback and metadata

    I rarely ever make posts like this, but if it saves anyone the 4 hours it took me to figure out then I feel I have done some good for this community.

    I don't know why, I don't know how, but for some reason setting the FLVPlayback.bufferTime property to anything past its default value of 0.1 will (more often than not) make it so the .flv metadata does not ever make it to the video player. Granted, this may also have to do with my slow connection, but I know I am not the only one who has had this problem (see http://www.actionscript.org/forums/s....php3?t=142403 or http://www.afcomponents.com/forum/vi...8f93428c976937)

    Those of you who have made players with custom seek-bars know the lack of metadata is can be a problem because the FLVPlayback.totalTime property is set directly from the "duration" property of the FLVPlayback.metadata object (see http://livedocs.adobe.com/flash/9.0/...html#metadata).

    My suspicion as to why this is not a more widespread issue is due to the "one video per player" nature of players on websites. I don't believe that players often reuse the net connection of the same FLVPlayback control to load one video after another (however, I could be wrong, this is all assumption on my part anyways).

    Anyways, if your custom video player falls under the most or all of the following criteria, I may have a solution for you

    1) The FLVPlayback's net connection is reused (that is, you call the load() or play() method several times during the lifetime of the videoplayer.

    2) You notice that occasionally meta information is never received when you increase the buffer time to a value above the default.

    3) Your seek-bar does respond or you get a run-time error when you try to seek (most likely because totalTime property NaN and the playheadPercentage property relies on this value)

    The simple solution (or so I am led to believe ):

    set the buffer time back to the default value before every call to the new connection. In other words, make sure that the the FLVPlayback.bufferTime property is set to 0.1 before calling the load() or play() method for a new video. This will ensure that the metadata is properly received by the component for playhead calculations.

    For those of you implementation bound people, I have a simple example below:

    Code:
    //assume we have an existing FLVPlayback component
    myFLVplayback:FLVPlayback = this.flvPlayer as FLVPlayback;
    
    //make sure to attach the meta handler for your player
    myFLVplayback.addEventListener(MetadataEvent.METADATA_RECEIVED, startVideo);
    
    //a call to the player to load a new video. notice I set the buffer time back to default
    myFLVplayback.bufferTime = .1;
    myFLVplayback.load("newVideo.flv");
    
    //the meta handler
    function startVideo(m:MetadataEvent):void
    {
           if(m.info.duration != undefined)
           {
    	     player.bufferTime = 10;
    	     player.playWhenEnoughDownloaded();
            }
            else trace("no duration info in metadata!");
    }
    and there you have it! I hope it does more good than bad. And if this really is a replicatable problem, I sincerely hope someone at adobe is reading this.

    Regards,

    Jon

  2. #2
    Junior Member
    Join Date
    Nov 2008
    Posts
    1
    Major thanks for this post Jon. I had the exact problem and your solution worked nicely.

  3. #3
    Junior Member
    Join Date
    Sep 2008
    Posts
    2
    Awesome. My work was warranted after all

  4. #4
    Junior Member
    Join Date
    Nov 2005
    Posts
    1
    Thanks a lot Jon

    I'd spent a lot longer than 4 hours trying to fix that problem.

    The handle on my custom seekbar was immediately disappearing while streaming flvs using a slow internet connection. Tests showed that the metadata wasn't coming across, but I couldn't understand why. Weird that notching up the buffer time above the default should have such an effect.

    Great to find such a simple answer.

    Cheers!

    Phil
    Last edited by Philip Barnard; 01-15-2009 at 07:21 PM.

  5. #5
    Junior Member
    Join Date
    Jan 2009
    Posts
    11
    Thanks for the tip! That helped me with 1 of the issues I was having with the seeking!

  6. #6
    newb of many sorts Ralgoth's Avatar
    Join Date
    Apr 2002
    Posts
    466
    Awesomeness.

    I had the same problem but didn't realize it was related to the bufferTime. Your post was luckely the first one I clicked on after searching.

    Thanks Jon!
    Search first, asked questions later.

  7. #7
    Member
    Join Date
    Jun 2003
    Posts
    86
    Thanks, this saved me a hunt for what I may say a rather undocumented 'feature'...

  8. #8
    Junior Member
    Join Date
    Jun 2008
    Posts
    10
    hi

    anybody have same solution in AS 2

    vineet
    Last edited by vineetpkl; 03-19-2009 at 10:22 AM. Reason: as2

  9. #9
    Junior Member
    Join Date
    Jun 2010
    Posts
    1
    i'm having a similar issue, totalTime returns 0 so i can't use my custom seek bar.

    at first sight code seems right, but i can't get it to work. does "flvPlayer", "myFLVplayback" and the "player" variables refer to the same object?

    any help will be appreciated.

  10. #10
    Junior Member
    Join Date
    Jul 2010
    Posts
    1
    Thank you for this! I just lost a few hours on this bug and you saved me a few more!
    For the record, I'm running into this error on a fiber optic connection, so connection speed may not be related to it.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center