如何在Django中播放本地文件夹中的视频?

问题描述 投票:0回答:1

我正在使用django应用程序进行异常检测项目。我试图从Django应用中的本地文件夹播放视频,但卡住了。如何播放视频?

python django
1个回答
0
投票

将这小段代码添加到模板中,它应该为您完成工作。

{% load staticfiles %} 

<video width="430" height="340" controls autoplay>
  <source src="{% static "video_file_name.mp4" %}" type="video/mp4"> </source> #give your video file name here
</video>

# Make sure you have copied your video file into your django projects static folder
# And specified static path in settings.py
settings.py

STATICFILES_DIRS = (os.path.join(BASE_DIR, "static"), )
© www.soinside.com 2019 - 2024. All rights reserved.