views:

177

answers:

2

I'm trying to add a cuepoint to a video using OSMF. I built an OSMF video player, and I'd like to use this instead of the FLVPlayback component, which seems like the only way to add an actionscript cuepoint?

Anyhow, I created a cuepoint by writing this:

var cuePoint:CuePoint = new CuePoint(CuePointType.ACTIONSCRIPT, 1, "good point", null);
            videoElement.addEventListener(MediaElementEvent.METADATA_ADD, onMetadataAdd);

            trace(cuePoint.time);

The cuepoint time traced out to "1" (successful).

I then took this code from the documentation, thinking it would help trace the cuepoint when I published my movie (to test the video)

private function onMetadataAdd(event:MediaElementEvent):void
        {
            if (event.namespaceURL == CuePoint.DYNAMIC_CUEPOINTS_NAMESPACE)
            {
                var timelineMetadata:TimelineMetadata = videoElement.getMetadata(CuePoint.DYNAMIC_CUEPOINTS_NAMESPACE) as TimelineMetadata;
                timelineMetadata.addEventListener(TimelineMetadataEvent.MARKER_TIME_REACHED, onCuePoint);
            }
        }

        private function onCuePoint(event:TimelineMetadataEvent):void
        {
            var cuePoint:CuePoint = event.marker as CuePoint;
            trace("Cue Point at " + cuePoint.time);
        }

However, I don't get a trace message when the video hits 1 second. Can anyone help me?

A: 

I think it should be just private function onMetadata.

adamcodes
You know what, that actually worked (I've gotten other responses that didn't help)...THANKS!!
redconservatory
Cool. If that's the answer, don't forget to give me a check :)
adamcodes
A: 

Here is another way to add cuepoints that's a little simpler:

    private function addVideoWithACuePoint()
    {
    url:String = "your-url";
    resource = new URLResource(url);
    videoElement = new VideoElement(resource);

    player = new MediaPlayer();
    player.media = videoElement;

    conainer = new MediaContainer(); 
    container.addMediaElement(videoElement);
    myTimelineMetadata = new TimelineMetadata(videoElement);
    myTimelineMetadata.addEventListener(TimelineMetadataEvent.MARKER_TIME_REACHED, onCuePointHandler, false, 0, true); 

   // add a cuepoint below:
    var cuePoint = new CuePoint(CuePointType.ACTIONSCRIPT,time, name, parameters);                  
    myTimelineMetadata.addMarker(cuePoint); 
}

Basically:

  • create your player and container
  • add your video element to your player
  • then you can create new timeline metadata from the video element
  • then you can add cuepoints
redconservatory