简体   繁体   English

为什么即使我使用正确的格式,html5视频标签也无法在Firefox中运行?

[英]Why does html5 video tag does not work in Firefox even if I'm using the right format?

I was trying to add a video to my web page with tag, but the tag doesn't work correctly. 我试图使用标签将视频添加到我的网页,但标签无法正常工作。 Here is the code: 这是代码:

<video src="/static/videos/test1.webm" type="video/webm" controls></video>

In the web-player I get "No video with supported format and MIME type found" error. 在网络播放器中,出现“找不到支持格式和MIME类型的视频”错误。 In the Internet some people say that it is the server problem and the main problem is in .htaccess server file. 在Internet中,有人说这是服务器问题,主要问题是.htaccess服务器文件。 But I'm using Django default web-server and there is no such file here. 但是我正在使用Django默认的Web服务器,这里没有这样的文件。 How can I solve this problem? 我怎么解决这个问题?

For a quick fix-- just focus on the part in bold. 快速修复-只需将重点放在粗体部分即可。 For details you may read the entire thing. 有关详细信息,您可以阅读全文。

Error is probably in your static files path. 错误可能出在您的静态文件路径中。 Above src should work if you have your test1.webm video in directory structure as follows: 如果您的test1.webm视频具有以下目录结构,则上面的src应该可以工作:

project/app_name/static/app_name/test1.webm  # when app_name= videos

But this should have worked default. 但这应该可以正常工作。 So I think you have created a new static folder directly in your project (outside all apps) with following directory structure: 因此,我认为您直接在项目中(所有应用程序之外)使用以下目录结构创建了一个新的静态文件夹:

project/static/videos/test1.webm

To make this work put following code in your project/project/settings.py 为此,请在您的project/project/settings.py以下代码

STATICFILES_DIRS = [  #for static assets that aren’t tied to a particular app
    os.path.join(BASE_DIR, "static"),
    '/var/www/static/',
]

To take it a step further if you have tried to deploy your django website, you may have moved settings.py to another settings directory and renamed it base.py file: project/project/settings/base.py 如果尝试部署django网站,则要更进一步,您可能已将settings.py移至另一个settings目录,并将其重命名为base.py文件: project/project/settings/base.py

In that case change your BASE_DIR in new base.py file to : 在这种情况下,将新base.py文件中的BASE_DIR更改为:

BASE_DIR = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM