Search code examples
flashvideoflv

Flash: Show text layer at a specific time in flash video


I'd like to play load/play one movie and show text at a specific times. In the Movie there is a scene where a board is shown. I'd like to show some text on the board when it appears. That's why I'd like to how to know when you reached a certain point.

Also about loading the video. I read there a several ways of loading a movie. What would be the best way in your opinion to load it in this situation.

1)Can this be done with the FLVPlayer component or through another way? If you can advise which way I should load and play the video, that would be great.

2) How to show a text at a specific time. Is there a function that I can use.

I really appreciate it you making time to answer this.

Thanks in advance.

Gosa


Solution

  • If you can encode cue points into your video, better yet, but you can also programmatically add cuepoints to a video using the addASCuePoint() method of the FLVPlayback component. (You can roll your own video component to handle these too, but the FLVPlayback component takes out much of the work).

    I'd suggest reading through the FLVPlayback reference, but in general, something like the following AS3 code should work:

    import fl.video.*;
    
    function flvReady(evt:VideoEvent):void {
        // Assuming the cuepoint should occur 12.2 seconds into the video. Unless the cues
        // are embedded in the video, you'll need to time this.
        flvPlayer.addASCuePoint(12.2, "boardShown");
    }
    
    function flvCuePoint(evt:MetadataEvent):void {
    
        if (evt.info.name == "boardShown")  {   
            // Here, trigger your titles/text/whatever fancy actions you want to trigger. For example, assuming a text field named
            // textLabel exists on stage, you might...
            textLabel.text = "Look! It's that board I talked about!";
        }
    }
    
    var flvPlayer:FLVPlayback = new FLVPlayback();
    flvPlayer.addEventListener(VideoEvent.READY, flvReady);
    flvPlayer.addEventListener(MetadataEvent.CUE_POINT, flvCuePoint);
    flvPlayer.source = "/path/to/video/of/board.flv";
    
    addChild(flvPlayer);