views:

179

answers:

2

Hi i'm loading a FLV into a blank video holder and would like to display a button when the video reaches a certain point. Is this at all possible?

+1  A: 

You didn't specify the version of actionscript in use, so I'll assume you're using as3.

You could

  1. use cue points embedded in the flv (added when creating the flv)
  2. if you're using the FLVPlayer component, use cue points created with actionscript
  3. use a regular Timer

If you don't have access to the creating-the-flv-part, the simplest (and the most inaccurate, but I would assume that displaying a button doesn't need to be millisecond-level-accurate) solution would be number three. If the user has no control over the playback (i.e. pause, rewind) and the video isn't being streamed over network, just start/stop a timer with the playback. If the user can pause and rewind the video, you'll have to also stop and adjust the timer every time the user does so. If the video is being streamed over network, you'll have to take any buffering pauses into account, too.

kkyy
+1  A: 

You can add cuepoint and listen for them with:

_Player.AddEventListener(MetadataEvent.CUE_POINT, PlayerCuePoint);

function PlayerCuePoint(e:MetadataEvent):void
{
    _Button.visible = true;
}

Or you could check the progress like this:

const BUTTON_TIME:Number = 10; //Time in seconds

_Player.AddEventListener(VideoEvent.PLAYHEAD_UPDATE, PlayerPlayheadUpdate);

function PlayerPlayheadUpdate(e:VideoEvent):void
{
    if(_Player.playheadTime >= BUTTON_TIME)
        _Button.visible = true;
}
Lillemanden