2013-05-13 73 views
1

我在我的django网站中使用JWPlayer 6。我想在同一页面上显示不同的视频。由于我正在遍历对象,因此我无法将不同的类ID分配给Jwplayer标记。所以,当我打开它,一个视频显示,而其他将弹出这个错误:无法使用JWplayer加载播放器

 Loading the player 

我一直在寻找一种方式来解决这个问题目前还没有成功!

Django的模板

{% block content %} 

    {% for flip in flips %} 

    <p> {{flip.title}} </p> 
     <center> 
      <div id="myElement">Loading the player...</div> 
      <script type="text/javascript"> 
       jwplayer("myElement").setup({ 
        image: "{{MEDIA_URL}}/{{flip.vid_image}}", 
      source[ {file: "{{MEDIA_URL}}/{{flip.vid_watch}}" }, 
       {file: "{{MEDIA_URL}}/{{flip.vid_mp}}" 
       ], 
        title:"{{flip.title}}", 
        width:692, 
        height:389 
       }); 
       </script> 
     </center> 
      <p>Description: {{flip.description}} </p> 
    {% endblock %} 
+0

这个其他StackOverflow线程有一个解决方案 - http://stackoverflow.com/questions/16152380/django-displaying-video-with-jwplayer – emaxsaun 2013-05-13 16:37:41

回答

1

下面是答案

{% block content %} 
    {% for flip in flips %} 
     <p> {{flip.title}} </p> 
    <center> 
     <div id="myElement_{{ forloop.counter }}">Loading the player...</div> 
      <script type="text/javascript"> 
      jwplayer("myElement_{{ forloop.counter }}").setup({ 
       image: "{{MEDIA_URL}}/{{flip.vid_image}}", 
       source[ {file: "{{MEDIA_URL}}/{{flip.vid_watch}}" }, 
         {file: "{{MEDIA_URL}}/{{flip.vid_mp}}"} 
       ], 
       title:"{{flip.title}}", 
       width:692, 
       height:389 
      }); 
      </script> 
     </center> 
     <p>Description: {{flip.description}} </p> 
     {% endfor %} 


    {% endblock %} 

感谢詹姆斯Herrieven!

相关问题