Solved

cue points in flvplayback: sycronising video and text

Posted on 2010-11-18
3
940 Views
Last Modified: 2013-11-11
I have a video that I'm playing in Flash using flvplayback and I need text to appear over the top of the video. The text fades in, stays for a while then fades out. At the moment I have my text animated on a timeline in a movieclip and placed on the stage. There is a stop action on the first frame of the movieclips containing the text animations and I have the following script to trigger the text off:

import fl.video.FLVPlayback;
import fl.video.MetadataEvent;

flvPlayBack.source = "video.flv";
flvPlayBack.addASCuePoint (0.1, "cue2");//add AS cue point
flvPlayBack.addEventListener (MetadataEvent.CUE_POINT, cp_listener2);
function cp_listener2 (ev:MetadataEvent):void
{
    if (ev.info.name == "cue2")
    {
            why_magee.gotoAndPlay(2);
    }
}

flvPlayBack.source = "video.flv";
flvPlayBack.addASCuePoint (14, "cue3");//add AS cue point
flvPlayBack.addEventListener (MetadataEvent.CUE_POINT, cp_listener3);
function cp_listener3 (ev:MetadataEvent):void
{
    if (ev.info.name == "cue3")
    {
            caption.gotoAndPlay(2);
    }
}

I works fine if you watch the video from start to finish, the text appears at the right time, does want it's supposed to but if I pause, rewind the video then the text animations animate independently from the timeline.

Is it possible to add the text I need with a different method so the timing of the text animations always matches the timing of the video (without adding the text to the original video file).

I'm using CS3 and AS3. Help would be much appreciated.

Thanks

Dan
0
Comment
Question by:Dan_Bailey
3 Comments
 
LVL 3

Accepted Solution

by:
IceColdas earned 500 total points
ID: 34282180
in order to get your task done, either you add cue points for each text position and when triggered play the text at the specified poisition,
or you sync your text with the playing time of the flv, and you add a timer with 200 ms (or less if necessary) trigger time and in that timer you check the playing time of the flv and according to that you set the related text.
For the second approach, you could use this code to start to play the texts. The code can be adjusted to display the texts even more precise, but ... that will imply some more coding.
import fl.video.*;
var flvPlayBack = new FLVPlayback();
flvPlayBack.source = "intro.flv";
this.addChild(flvPlayBack);
var myTexts:MovieClip = new MovieClip();
var currentTextPosition = -1;

var textTime:Array = new Array (3,  5, 14, 23); //  .... here goes your times .... 
var textFrame:Array = new Array (1,  70, 150, 300); //  .... here goes the starting frames for your texts .... 
var timer1:Timer = new Timer(200);
timer1.addEventListener(TimerEvent.TIMER, onTimer);
timer1.start();
function onTimer(ev:TimerEvent)
{
	var textPosition = getTextPosition(flvPlayBack.playheadTime);
	if (textPosition != currentTextPosition && textPosition != -1)
	{
		currentTextPosition = textPosition;
		ShowText(textPosition);
	}
}

function getTextPosition(playTime:Number)
{
	var textPosition:Number = -1;
	for (var i = 0; i < textTime.length - 1; i++)
	{
		if (playTime >= textTime[i] && playTime < textTime[i+1])
		{
			textPosition = i; break;
		}
	}
	return textPosition;
}
function ShowText(textPosition:Number)
{
	trace("showing text at frame:"+textFrame[textPosition]);
	myTexts.gotoAndPlay(textFrame[textPosition]);
}

Open in new window

0
 
LVL 37

Expert Comment

by:CyanBlue
ID: 34470594
This question has been classified as abandoned and is being closed as part of the Cleanup Program.  See my comment at the end of the question for more details.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Action Script commands 3 223
Action Script commands 4 326
Shockwave Flash Object within PowerPoint 2013 2 167
2012 Domain With 350 Machines All Running Windows 7 7 139
This is a very simple example to help those of you who are still migrating from AS2 to AS3 understand the redesigned event model in AS3. In AS2.0, event functions (that is, the function to be performed when an event is fired) were stored as a pro…
I have been doing hardcore actionscripting for some time; and needless to say I have faced a lot of problems in just understanding others' code rather than understanding what the code executes. A programmer's life can become hell when there are a lo…
The goal of the tutorial is to teach the user how to how to record live broadcast.
The goal of the tutorial is to teach the user how to use the auto adjust feature and what the different options do. When your video is not working right you can choose the auto adjust feature to help choose your settings.

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question