0

我有一个 zpt(zope 页面模板),我想在其中使用视频标签,例如:

<video src="FILE_LOCATION" width="320" height="240" type='video/ogg; codecs="theora, vorbis"' controls></video>

其中 FILE_LOCATION 将是 plone 的内容类型。我可以使用 3 种方式来访问文件:

1) file.download_url #gives me: http://localhost:8000/a/acervo/testeflv2/at_download/file
2) file.absolute_url #gives me: http://localhost:8000/a/acervo/testeflv2
3) file.getFile() #gives me the file (like if I open the video file on a text editor)

obs:如果我单击浏览器上第一个或第二个选项返回的链接,它会从浏览器打开下载窗口以下载文件。

在 zpt 上,我可以这样做:

<video src="" id="video_play" width="320" height="240" type='video/ogg; codecs="theora, vorbis"' controls
       tal:attributes="src python:file.absolute_url()"></video>

其中“python:file.absolut_url()”可以更改为其他选项。

但这些选项中的任何一个都有效。该页面向我显示了一个应该播放视频的块,但没有播放视频。
我怎样才能使这项工作?

4

2 回答 2

0

您可能需要下载链接 - 您需要纯数据,而不是 Plone 默认视图。

IE

<video src="" id="video_play"    width="320" height="240"    type='video/ogg; codecs="theora,    vorbis"' controls tal:attributes="src    file/download_url"></video>

如果这不起作用:

  • 您的浏览器是否支持 .ogg?(尝试同时使用 Firefox 和 chrome)
  • 真的是ogg吗?
  • 如果直接打开下载地址会怎样?浏览器会播放什么吗?
  • 渲染模板(查看源或检查元素)后 src 指向什么。网址看起来正确吗?
于 2010-09-07T06:14:49.410 回答
0

主要问题来自“Content-Disposition”标头。这是一个硬编码 ogg/theora 格式的示例。在您的自定义皮肤中创建一个脚本“inline_download”,其中包含以下代码:

RESPONSE =  container.REQUEST.RESPONSE

filename = context.getFilename()
obj = context.getFile()
RESPONSE.setHeader('Content-Disposition', 'inline;filename="%s"' % filename)
RESPONSE.setHeader('Content-Type', 'video/ogg')

return obj

现在http://yourpath/video/inline_download应该正确显示视频而无需额外的 html。

最后在您的视图中添加此代码:

<video height="240px" width="320px" type="video/ogg; codecs='theora, vorbis'"
       controls="controls" preloas="none"
       tal:attributes="src string:${here/absolute_url}/inline_download"/>
于 2010-11-25T13:18:15.637 回答