以编程方式注释 YouTube 视频 [英] Annotating YouTube videos programmatically

查看:19
本文介绍了以编程方式注释 YouTube 视频的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望能够显示带有重叠注释的普通 YouTube 视频,每个帧由彩色矩形组成.唯一的要求是这应该以编程方式完成.

YouTube 现在有注释,但需要您使用其前端手动创建.我希望能够生成它们.这样做的最佳方法是什么?

一些想法:

<块引用>

  1. 构建您自己的 Flash 播放器(嗯?)
  2. 不知何故在 YouTube Flash 播放器上绘制.这行得通吗?
  3. 逆向工程&劫持 YouTube 的注释系统.要么弄乱本地文件,要么重定向其下载尝试注释.(使用 Greasemonkey?Firefox 插件?)

不重要的想法:

<块引用>

下载视频

解决方案

YouTube 提供了一个 ActionScriptAPI.

使用此功能,您可以使用其 API 将视频加载到 Flash 中,然后让您的 Flash 应用在视频上方的图层上创建注释.

或者,如果您不想在 Flash 中创建内容,可以使用 YouTube 的 JavaScript API 在您网页上的 YouTube 播放器上绘制 HTML DIV.请记住,当您嵌入播放器时,参数列表中有 WMODE="transparent" .

所以使用来自 YouTube 的示例:

 

然后您应该能够使用 CSS/DHTML 在 YouTube 电影上绘制注释.

I want to be able to display a normal YouTube video with overlaid annotations, consisting of coloured rectangles for each frame. The only requirement is that this should be done programmatically.

YouTube has annotations now, but require you to use their front end to create them by hand. I want to be able to generate them. What's the best way of doing this?

Some ideas:

  1. Build your own Flash player (ew?)
  2. Somehow draw over the YouTube Flash player. Will this work?
  3. Reverse engineer & hijack YouTube's annotation system. Either messing with the local files or redirecting its attempt to download the annotations. (using Greasemonkey? Firefox plugin?)

Idea that doesn't count:

download the video

解决方案

YouTube provides an ActionScript API.

Using this, you could load the videos into Flash using their API and then have your Flash app create the annotations on a layer above the video.

Or, alternatively, if you want to stay away from creating something in Flash, using YouTube's JavaScript API you could draw HTML DIVs over the YouTube player on your web page. Just remember when you embed the player to have WMODE="transparent" in the params list.

So using the example from YouTube:

  <script type="text/javascript">

    var params = { allowScriptAccess: "always" };
    var atts = { id: "myytplayer", wmode: "transparent" };
    swfobject.embedSWF("http://www.youtube.com/v/VIDEO_ID&enablejsapi=1&playerapiid=ytplayer", 
                       "ytapiplayer", "425", "356", "8", null, null, params, atts);

  </script>

And then you should be able to draw your annotations over the YouTube movie using CSS/DHTML.

这篇关于以编程方式注释 YouTube 视频的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆