django用jwplayer无法播放视频

时间:2013-06-30 10:33:16

标签: django url static settings jwplayer

我正在写一个视频网站,它具有播放视频的功能,我使用jwplayer作为播放器,我设置了settings.py,以便在我的模板(show_video.html)中可以获得视频路径。问题是:我一直在 加载媒体时出错: 文件无法播放, 但我直接打开html文件,它可以播放视频...... 我的视频是MP4文件 任何帮助都是合适的 这是我的settings.py剪辑:

MEDIA_URL = '/media/'
STATIC_URL = '/static/'
STATICFILES_DIRS = (
     ('asset','/var/www/newproject/static'),
      # Put strings here, like "/home/html/static" or "C:/www/django/static".
      # Always use forward slashes, even on Windows.
       #Don't forget to use absolute paths, not relative paths.
 )

MEDIA_ROOT = '/var/www/newproject/media'
ADMIN_MEDIA_PREFIX='/admin_media/'

我在urls.py中添加了一段代码:

urlpatterns = patterns('',  
  url(r'^admin/', include(admin.site.urls)),
  url(r'^uploadFile$', 'pornsite.views.manage_video'),
  url(r'^playVideo/$','pornsite.views.show_video'),
  )

 urlpatterns += patterns('',(r'^media/(?P<path>.*)$', 'django.views.static.serve', {'document_root': settings.MEDIA_ROOT}))

这是我的模板(show_video.html):

<h1>mysite blog<h1>
        {% load static%}
{% block content %}
<h2>Video</h2>
<script src="http://jwpsrv.com/library/G7U50OC1EeKhaxIxOQulpA.js">
    </script>
<body>
        <div id='my-video'></div>
        <script type='text/javascript'>
            jwplayer('my-video').setup({

            file: "{{MEDIA_URL}}lWMJeVvV-364767.mp4",
            image: 'http://www.longtailvideo.com/content/images/jw-player/lWMJeVvV-876.jpg',
            width: '640',
            height: '360'});
    </script>
</body>

        {{MEDIA_URL}}        
{% endblock %}

这是我的Apache默认文件代码:  ServerAdmin webmaster @ localhost   3 Alias /robots.txt /usr/local/wsgi/static/robots.txt   4 Alias /favicon.ico /usr/local/wsgi/static/favicon.ico   5 Alias / static / /usr/local/lib/python2.7/dist-packages/django/contrib/admin/static/   6 AliasMatch ^ /([^ /] *。css)/ usr / local / wsgi / static / styles / $ 1   7   8 #Alias / media / / usr / local / wsgi / media /   9 Alias / static / / usr / local / wsgi / static /  10 AddType text / html .py  11  12  13 AllowOverride无  14选项无  15命令允许,拒绝  16允许所有

是否有人解决了这个问题?

尝试使用jwplayer示例代码:

<div id="container">jwplayer("container").setup({>
       flashplayer: "player.swf", 
       file: "http://streaming.openvideoads.org:81/shows/the-black-hole.mp4", 
       duration: 10,
       height: 300,
       width: 450,
       plugins: {
         "ova-jw": { 
             "regions": { 
                ...
             },
             "ads": {
                ...
             },
             "debug": { 
                ...
             }
         }
      }
});
</script>

0 个答案:

没有答案