OSMF - 向视频添加动作脚本提示点?

发布于 2024-09-04 13:22:34 字数 1140 浏览 5 评论 0原文

我正在尝试使用 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 秒时,我没有收到跟踪消息。谁能帮助我吗?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

蓬勃野心 2024-09-11 13:22:34

我认为它应该只是private function onMetadata

I think it should be just private function onMetadata.

相思故 2024-09-11 13:22:34

这是添加提示点的另一种更简单的方法:

    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); 
}

基本上:

  • 创建播放器和容器
  • 将视频元素添加到播放器
  • 然后您可以从视频元素创建新的时间线元数据
  • 然后您可以添加提示点

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
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文