Solved

cue points in flvplayback: sycronising video and text

Posted on 2010-11-18
3
941 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

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

I come across a lot of question about how to access things in the document class from a movieclip, or accessing something from a movieclip in the document class. It took me a while to figure this out but once I did it makes life so much easier. …
Recently, I was asked to recommend a tracking system to be implemented on a clients website. As the entire site was built on flash, my first thought was to suggest custom built tracking system. However, our company at that point of time didn't h…
In this tutorial viewers will learn how to create a basic motion tween animation in Flash Open a new document in Flash: Draw/import an image: Press CTRL + F8 to convert it into a graphic symbol: Select a frame (how long you want the tween to last): …
This Micro Tutorial will teach to how to utilize bit rate in Adobe Flash Media Live Encoder.

717 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