Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Django and HTML cannot start video from a specified time

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%23t%3D10%2C30
404 (Not Found)

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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?

>Solution :

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>
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading