
Hi.
Sorry for the long delay in posts. We had a new family addition and babies take precedence over blog entries.
I had to add dynamic cue points today and thought I would build a quick sample to share because cue points are very common in videos these days. I would think this would be more common on some blog entries but I did not see that many out there.
The key to building cue points through the VideoDisplay object is the CuePointManager. You can access it directly from the VideoDisplay object. HOWEVER.. You must define its class via the cuePointManagerClass in the VideoDisplay tag area otherwise accessing it via the VideoDisplay comes back with a null object.
Ex: <mx:VideoDisplay id=”videoPlayer” source=”video/sample.flv” cuePointManagerClass=”mx.controls.videoClasses.CuePointManager” />
Anyway. I hope this example works for you and shows you an easy way to implement Cue Points in Flex.
Thanks,
Kev.
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
creationComplete="handleCreationComplete();"
layout="absolute"
width="400" height="300"
borderColor="#E63F3B"
backgroundGradientAlphas="[0.86, 1.0]"
backgroundGradientColors="[#DA3737, #922424]">
<mx:Script>
<![CDATA[
import mx.events.CuePointEvent;
import mx.controls.videoClasses.CuePointManager;
// called up creation complete
public function handleCreationComplete():void
{
// get cuePointManager
var cuePM:CuePointManager = videoPlayer.cuePointManager as CuePointManager;
// add cue point
var obj:Object;
obj = new Object();
obj.name = "Cue #1";
obj.time = 1.0;
cuePM.addCuePoint(obj);
// add cue point
obj = new Object();
obj.name = "Cue #2";
obj.time = 5.0;
cuePM.addCuePoint(obj);
// add cue point
obj = new Object();
obj.name = "Cue #3";
obj.time = 10.0;
cuePM.addCuePoint(obj);
// add cue point
obj = new Object();
obj.name = "Cue #4";
obj.time = 15.0;
cuePM.addCuePoint(obj);
// add event listener
videoPlayer.addEventListener(CuePointEvent.CUE_POINT,this.handleCuePointEvent);
}
// handles que point event
public function handleCuePointEvent(e:CuePointEvent):void
{
nameText.text = e.cuePointName;
timeText.text = e.cuePointTime.toString();
}
// handles video stop
public function handleStop():void
{
videoPlayer.stop();
nameText.text = timeText.text = "";
}
// handles video play
public function handlePlay():void
{
videoPlayer.play();
}
]]>
</mx:Script>
<mx:VideoDisplay id="videoPlayer" source="video/sample.flv" cuePointManagerClass="mx.controls.videoClasses.CuePointManager" x="80" y="22" width="240" height="180" autoPlay="false"/>
<mx:Text id="header" selectable="false" x="80" y="0" text="Dynamic Cue Points Example" enabled="true" fontFamily="Arial" fontWeight="bold" fontSize="16" color="#FAFBFB"/>
<mx:Button id="stopBtn" buttonMode="true" x="144.5" y="210" label="Stop" click="handleStop();" color="#000000"/>
<mx:Button id="playBtn" buttonMode="true" x="204.5" y="210" label="Play" click="handlePlay();"/>
<mx:TextArea x="220.5" y="240" width="62" height="20" fontFamily="Arial" fontSize="12" fontWeight="bold" id="nameText"/>
<mx:TextArea x="220.5" y="268" width="62" height="20" fontFamily="Arial" fontSize="12" fontWeight="bold" id="timeText"/>
<mx:Label x="117.5" y="243" text="Cue Point Name:" fontWeight="bold" color="#F6FBFC"/>
<mx:Label x="119.5" y="271" text="Cue Point Time:" fontWeight="bold" color="#F6FBFC"/>
</mx:Application>




