首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Django在本地嵌入静态m4v

Django在本地嵌入静态m4v
EN

Stack Overflow用户
提问于 2015-01-06 01:52:54
回答 1查看 195关注 0票数 1

M4V是一种文件格式,如何嵌入带有.m4v扩展名静态文件,

代码语言:javascript
复制
<object classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B"     
 codebase="http://www.apple.com/qtactivex/qtplugin.cab" width="320" height="256" >
<param name="src" value="/static/example.m4v">

<param name="autoplay" value="false">

<param name="controller" value="true">

 <embed src="/static/example.m4v" type="video/mp4" width="320" height="256" controller="true"    controls="true" autostart="false"/>

  </object>

上面的例子强制它下载。

http://django-embed-video.readthedocs.org/en/v0.11/index.html只适用于youtube等在线网站,其他网站则很少。

EN

回答 1

Stack Overflow用户

发布于 2016-12-22 06:17:15

我也在为同样的问题苦苦挣扎。我几乎是抄袭了http://camendesign.com/code/video_for_everybody的代码。

代码语言:javascript
复制
<!-- first try HTML5 playback: if serving as XML, expand `controls` to `controls="controls"` and autoplay likewise -->
<!-- warning: playback does not work on iOS3 if you include the poster attribute! fixed in iOS4.0 -->
<video width="640" height="360" controls>
    <!-- MP4 must be first for iPad! -->
    <source src="__VIDEO__.MP4" type="video/mp4" /><!-- Safari / iOS video    -->
    <source src="__VIDEO__.OGV" type="video/ogg" /><!-- Firefox / Opera / Chrome10 -->
    <!-- fallback to Flash: -->
    <object width="640" height="360" type="application/x-shockwave-flash" data="__FLASH__.SWF">
        <!-- Firefox uses the `data` attribute above, IE/Safari uses the param below -->
        <param name="movie" value="__FLASH__.SWF" />
        <param name="flashvars" value="controlbar=over&amp;image=__POSTER__.JPG&amp;file=__VIDEO__.MP4" />
        <!-- fallback image. note the title field below, put the title of the video there -->
        <img src="__VIDEO__.JPG" width="640" height="360" alt="__TITLE__"
             title="No video playback capabilities, please download the video below" />
    </object>
</video>
<!-- you *must* offer a download link as they may be able to play the file locally. customise this bit all you want -->
<p> <strong>Download Video:</strong>
    Closed Format:  <a href="__VIDEO__.MP4">"MP4"</a>
    Open Format:    <a href="__VIDEO__.OGV">"Ogg"</a>
</p>

然后确保创建包含以下内容的.htaccess文件:

代码语言:javascript
复制
AddType video/ogg  .ogv
AddType video/mp4  .mp4
AddType video/webm .webm

此外,我在我的项目中使用了较旧版本的django (1.6.5),我将视频存储在我的MEDIA_ROOT中,并在settings.py中设置了MEDIA_URL,以便视频的来源如下所示:

代码语言:javascript
复制
{{ MEDIA_URL }}/media/videos/video.m4v
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/27785047

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档