2

I am currently trying to display a video on a website using jwplayer. The view for the page is

def video(request): return render_to_response('video_player/video.html', context_instance=RequestContext(request) 

And the html template being used contains this in the head:

<script type="text/javascript" src="/jwplayer/jwplayer.js"></script> 

And this in the body:

<div id="myElement">Loading the player...</div> <script type="text/javascript"> jwplayer("myElement").setup({ file: "{{ MEDIA }}videos/test.mp4", image: "{{ MEDIA }}videos/cute-bunny.jpg" }); </script> 

It doesn't display anything other than 'Loading the player', i think there may be something wrong with me calling the media_root. It is defined as:

MEDIA_ROOT = 'C:/Users/Timmy/Documents/GitHub/GroupProject/media' 
1
  • Do you have a link we can look at? Commented Apr 22, 2013 at 18:02

1 Answer 1

2

You should be using the {{ MEDIA_URL }} tag in your templates, which you define in settings.py.

Example in settings.py:

MEDIA_URL = '/media/' 

MEDIA_ROOT, like STATIC_ROOT, is the directory that Django uses to upload media files to and serve media files from, not the URL path.

See: https://docs.djangoproject.com/en/dev/howto/static-files/#serving-files-uploaded-by-a-user

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.