2011-03-10 63 views
0

所以我在我的WordPress站點上使用jsplayer HTML5播放器,以及一些自定義腳本在下一篇文章中加載並在視頻完成後替換舊內容:html5視頻播放列表在wordpress中使用ajax通過jquery

$(document).ready(function(){ 
     $(".video-js").livequery('ended', function(){ 
      var sStr = "<?php echo get_permalink(get_adjacent_post(true,'',true)); ?>"; 
      var adj_numb = "<?php 
          $adj = get_adjacent_post(true,'',true); 
          $numb = $adj->ID; 
          echo $numb 
          ?>"; 
      var cur_numb = "<?php echo $post->ID; ?>"; 
      $.post(sStr, function(data) { 
       var content = $(data).find('#post-' + adj_numb); 
       $("#post-" + cur_numb).html(content); 
       var vid = VideoJS.setup("vid"); 
       vid.play(); 
      }); 
     }); 
    }); 

這很好,2視頻。它在下一個視頻中加載並播放,之後播放,但在第3個視頻播放後,它停止播放。我想這意味着我必須對所有變量進行「重置」,然後從腳本開始重新開始,並且由於$(document).ready(function(),因爲它已經全部加載這點。

是否有循環標準的方式,通過這個腳本再次,並重新設定所有的變量及其運行一次?

後還是我錯誤地接近整個問題?

謝謝!

渲染JS:

$(document).ready(function(){ 
     $(".video-js").livequery('ended', function(){ 
      var sStr = "http://www.theloniousfilms.com/zachmath/volkswagon/"; 
      var adj_numb = "94"; 
      var cur_numb = "96"; 
      $.post(sStr, function(data) { 
       var content = $(data).find('#post-' + adj_numb); 
       $("#post-" + cur_numb).html(content); 
       var vid = VideoJS.setup("vid"); 
       vid.play(); 
      }); 
     }); 
    }); 

HTML:

<div class="post-96 post type-post status-publish format-standard hentry category-zachmath" id="post-96"> 
      <h2 id="director">Director Name</h2> 

      <h2 id="post_title">Post-Name 
       <span id="post_name"> 

       "Hot Tub" 
       </span> 
       <span id="home"><a href="http://www.homelink.com/">HOME</a></span> 

       <div class="entry"> 

        <div class="video-js-box"> 
     <!-- Using the Video for Everybody Embed Code http://camendesign.com/code/video_for_everybody --><br /> 
     <video id="vid" class="video-js" width="640" height="360" preload autoplay poster="http://www.site.com/wp-content/uploads/2011/03/poster.jpg"><br /> 
      <source src="http://d29zgp48wvs9kv.cloudfront.net/orkin.m4v" type='video/mp4; codecs="avc1.42E01E, mp4a.40.2"' /><br /> 

      <source src="http://d29zgp48wvs9kv.cloudfront.net/orkin.ogv" type='video/ogg; codecs="theora, vorbis"' /><br /> 
      <!-- Flash Fallback. Use any flash video player here. Make sure to keep the vjs-flash-fallback class. --><br /> 
      <object class="vjs-flash-fallback" width="640" height="360" type="application/x-shockwave-flash"<br /> 
      data="http://releases.flowplayer.org/swf/flowplayer-3.2.1.swf"><param name="movie" value="http://releases.flowplayer.org/swf/flowplayer-3.2.1.swf" /><param name="allowfullscreen" value="true" /><param name="flashvars" value='config={"playlist":["http://www.theloniousfilms.com/wp-content/uploads/2011/03/poster.jpg", {"url": "http://d29zgp48wvs9kv.cloudfront.net/orkin.m4v","autoPlay":true,"autoBuffering":true}]}' /><!-- Image Fallback. Typically the same as the poster image. --><br /> 
      </object><br /> 
     </video> 
     </div> 

回答

0

我結束了一個不同的方法,在這裏我把所有的帖子的網址爲數組,然後通過他們每個人重複去,去到下一個項目在一個數組一次回放完了。