Home > Blockchain >  Django and HTML cannot start video from a specified time
Django and HTML cannot start video from a specified time

Time:09-03

I am trying to start playing a video from a specific location using Django:

<video controls autoplay id='vid' muted >
 <source src="{% static 'vids/videoplayback.mp4#t=10,30' %}" type="video/mp4">
</video>

This gives an error

GET http://127.0.0.1:8000/static/vids/videoplayback.mp4#t=10,30 404 (Not Found)

as it seems Django automatically escaping the special characters is the culprit. Removing the #t=10,30 will autoplay the video without any issue.

How do I fix this?

CodePudding user response:

You can set attrs as strings with the mustache-syntax e.g.: {{ 'random string' }}. Like this:

<video controls autoplay id='vid' muted >
 <source src="{% static 'vids/videoplayback.mp4' %}{{ '#t=10,30' }}" type="video/mp4">
</video>
  • Related