Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

cue points in flvplayback: sycronising video and text

Posted on 2010-11-18
3
Medium Priority
?
944 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 2000 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

Industry Leaders: 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

This is intended to introduce all collision detection principles in flash, their strengths, weaknesses and workarounds. The main method for Collision Detection in flash is using hitTestObject. But unless you'll be pushing rectangular shapes without …
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. …
The goal of the tutorial is to teach the user how to live broadcast using Flash Media Live Encoder and connecting it to YouTube to broadcast. Log into your Youtube account, choose live stream settings, start live stream from Flash Media Live Enc…
The goal of the tutorial is to teach the user how to select the video input device. Make sure you have an input device that in connected and work and recognized by Adobe Flash Media Live Encoder and select it in the “video input” menu.

636 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