我目前正在尝试使用 jwplayer 在网站上显示视频。页面的视图是
def video(request):
return render_to_response('video_player/video.html', context_instance=RequestContext(request)
正在使用的 html 模板的头部包含以下内容:
<script type="text/javascript" src="/jwplayer/jwplayer.js"></script>
这在身体里:
<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>
除了“正在加载播放器”之外,它不显示任何其他内容,我认为我调用 media_root 可能有问题。它定义为:
MEDIA_ROOT = 'C:/Users/Timmy/Documents/GitHub/GroupProject/media'
您应该使用{{ MEDIA_URL }}
模板中的标记,您在 settings.py 中定义。
settings.py 中的示例:
MEDIA_URL = '/media/'
MEDIA_ROOT 与 STATIC_ROOT 一样,是目录Django 用于上传媒体文件并从中提供媒体文件的路径,而不是 URL 路径。
See: https://docs.djangoproject.com/en/dev/howto/static-files/#serving-files-uploaded-by-a-user https://docs.djangoproject.com/en/dev/howto/static-files/#serving-files-uploaded-by-a-user
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)