1

我正在编写一个具有播放视频功能的视频网站,我使用 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>
4

0 回答 0