Reply
Contributor
cicerone
Posts: 32
Registered: ‎01-20-2009
0 Kudos
Accepted Solution

Can't get cue point event to fire in Flex

Here's a snippet of relevant code:

 

            private function cueVideo():void
            {
                _videoPlayerModule.cueVideo(_videoID);
                _videoPlayerModule.addEventListener(MediaEvent.BEGIN, registerCuePoints);               
            }
           
            private function registerCuePoints(event:MediaEvent):void
            {
                var overlayPoints:Array = new Array (1000, 2000, 3000, 4000);
                _cuePointsModule.addCuePoints(_videoID, overlayPoints);
                _cuePointsModule.addEventListener(CuePointEvent.CUE, onCuePoint);
                var cueArrayTest:Array = _cuePointsModule.getCuePoints(_videoID);
            }
           
            private function onCuePoint(event:CuePointEvent):void
            {
            trace("Cue!"); 
            }

 

I'm getting the my test array back as Video DTOs. I'm including all events just in case:

 

        import com.brightcove.api.events.*;

 

I'm not getting any code editor, compile or runtime errors. I just never get my trace...

Brightcove Team
BC-ChrisD
Posts: 121
Registered: ‎12-07-2008
0 Kudos

Re: Can't get cue point event to fire in Flex

Cicerone,

 

You should try specifying your times in Seconds, instead of milliseconds. I'm not sure if our docs are clear on this point but in my examples I've had better luck with seconds.

Christopher DeGrace
Product Manager
Contributor
cicerone
Posts: 32
Registered: ‎01-20-2009
0 Kudos

Re: Can't get cue point event to fire in Flex

The documentation (API reference) does say milliseconds. But I did try:

 

var overlayPoints:Array = new Array (1, 2, 3, 4);

 

And was not able to get a trace. Do they need to be formatted in a certain way and/or strongly typed?

 

Also, the cue points module itself gives me this constant in code hinting:

 

CuePointEvent.CUE_POINT (while CuePointEvent itself has CuePointEvent.CUE)

 

I've tried using either one or even just the string "cuePoint" (with a generic event:Event handler)...

Brightcove Team
BC-ChrisD
Posts: 121
Registered: ‎12-07-2008
0 Kudos

Re: Can't get cue point event to fire in Flex

[ Edited ]

I've attached an example that I have that is working even though it's not using the PlayerAPI SWC so it might be a little different.

 

If I had to guess I'd think it was the section where you are creating the Cue points that is the problem. Here is how I'm doing it:

 

 

var newCuePoint:Object = new Object();
newCuePoint.assetId = null;
newCuePoint.forceStop = false;
newCuePoint.metadata = null;
newCuePoint.name = "Programmatically Added";
newCuePoint.time = 1;
newCuePoint.version = 0;
newCuePoint.videoId = 1375772128;
newCuePoint.type = 0; // 0 Ad, 1 Code, 2 Chapter, 3 Ad Impression

cue = player.getModule("cuePoints");

cue.addCuePoints(1375772128, [newCuePoint]);
// videoId, array of cue points

 

 

 

Message Edited by BC-ChrisD on 05-22-2009 02:29 PM
Christopher DeGrace
Product Manager
Contributor
cicerone
Posts: 32
Registered: ‎01-20-2009
0 Kudos

Re: Can't get cue point event to fire in Flex

Works great in Flash, but not in Flex. I'm using the Flex component. I did try just using the plain SWC wrapper as well.

 

I am getting an array back via:

 

var cueArrayTest:Array = _cuePointsModule.getCuePoints(_videoID);

 

So the cue points are sitting there, but just not firing for some reason from the CuePointsModule. Any chance there's something missing in the SWC?

Brightcove Team
BC-Todd
Posts: 746
Registered: ‎12-21-2008
0 Kudos

Re: Can't get cue point event to fire in Flex

There is currently a bug with the player (not the SWC, and not Flex specific, which is why this initially confused me) where adding a cue point to a video that is already playing *that doesn't currently have any other cue points previously set* will not work. You can add a cue point to a video that is not yet playing (such as if it is in a playlist), but not to the current video. This is fixed in our next release.

 

The simplest workaround right now is to enable adds for the video and the player, but don't target ads to the player (if you have control over that). If you have ads enabled, a preroll and postroll cue point is automatically added, which then enables you to programmatically add other cue points.

 

I was able to get cue points firing in a new Flex project using the current SWC I just downloaded tonight. The following code is all I have in my project, along with the BrightcovePlayer snippet and a reference to the SWC. With ads enabled, the 10 second cue point fires. With ads turned off, the cue point does not fire.

 

<?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:bc="com.brightcove.api.*" layout="vertical" width="600" height="500" > <mx:Script> <![CDATA[ import com.brightcove.api.APIModules; import com.brightcove.api.modules.CuePointsModule; import com.brightcove.api.events.CuePointEvent; import com.brightcove.api.events.MediaEvent; import com.brightcove.api.modules.VideoPlayerModule; private var _videoPlayer:VideoPlayerModule; private function onCueVideo(event:MouseEvent):void { _videoPlayer = _player.getModule(APIModules.VIDEO_PLAYER) as VideoPlayerModule; _videoPlayer.addEventListener(MediaEvent.BEGIN, onMediaBegin); _videoPlayer.cueVideo(123456789); } private function onMediaBegin(event:MediaEvent):void { _videoPlayer.removeEventListener(MediaEvent.BEGIN, onMediaBegin); var cuePointModule:CuePointsModule = _player.getModule(APIModules.CUE_POINTS) as CuePointsModule; cuePointModule.addCuePoints(_videoPlayer.getCurrentVideo().id, [10]); cuePointModule.addEventListener(CuePointEvent.CUE, onCuePoint); } private function onCuePoint(event:CuePointEvent):void { trace(event.cuePoint.time); } ]]> </mx:Script> <bc:BrightcoveFlexComponent id="_player" playerClass="BrightcovePlayer" width="486" height="412"/> <mx:Button click="onCueVideo(event)" label="click me" /> </mx:Application>

 

--todd
Contributor
cicerone
Posts: 32
Registered: ‎01-20-2009
0 Kudos

Re: Can't get cue point event to fire in Flex

Thanks! I was going crazy trying to figure this one out.