I am trying to play a video by using django with html5 video tag but couldn't.
The main problem is that the server cannot get a video
file.
I got this error:
[06/Jan/2014 23:52:07] "GET absolute_path_of_media/sample.mp4 HTTP/1.1" 404 2422
and in inspect elements:
Here, I will show you my code.
templates/videoplay.html:
{% extends "app/base.html" %}
{% block contents %}
<video name='demo' controls autoplay width='50%' height='40%'>
<source src="{{media}}/sample.mp4" type="video/mp4"></source>
</video>
{% endblock %}
views.py:
def index(request):
return render(request, "app/videoplay.html", {'media': MEDIA_ROOT})
I imported MEDIA_ROOT
from settings.py and it is absolute path of media directory.
develop environment:
browser: chrome
django:1.6.1
python:2.7
static and media directories' relation:
mysite/
static/
sample.mp4
media/
sample.mp4
templates/
....
views.py
....