我正在尝试使用OSMF为视频添加提示点。我构建了一个OSMF视频播放器,我想使用它来代替FLVPlayback组件,这似乎是添加动作脚本提示点的唯一方法吗?
无论如何,我通过写这个来创建一个提示点:
var cuePoint:CuePoint = new CuePoint(CuePointType.ACTIONSCRIPT, 1, "good point", null);
videoElement.addEventListener(MediaElementEvent.METADATA_ADD, onMetadataAdd);
trace(cuePoint.time);
提示点时间追溯到“1”(成功)。
然后我从文档中获取了这段代码,认为这有助于在发布我的电影时跟踪提示点(以测试视频)
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);
}
但是,当视频达到1秒时,我没有收到跟踪消息。谁能帮我?
答案 0 :(得分:2)
我认为它应该只是private function onMetadata
。
答案 1 :(得分:1)
这是另一种添加更简单的提示点的方法:
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);
}
基本上: