2017-05-05 94 views
0

夥計。我有上面的腳本播放我的視頻。我試過使用VideoJS,它不起作用。我在下面的腳本播放所有視頻,但我無法讓它播放隨機播放。你們可以幫我做到這一點嗎,所以它隨機播放視頻?如何讓這位玩家隨機?

<script> 
$(document).ready(function(){ 
    var video = document.getElementById('player'); 
    var vids = ["videos/COMBATE-A-TUBERCULOSE.mp4", 
    "videos/Pilula-01.mp4", 
       "http://jell.yfish.us/media/jellyfish-3-mbps-hd-h264.mkv"]; 
    var current_vid = 0; 
    video.volume = 0.2; 
    video.setAttribute("src", vids['0']); 
    $('video').on('ended',function(){ 
     current_vid = +current_vid + 1; 
     if(typeof vids[current_vid] == 'undefined'){ 
      current_vid = 0; 
     } 
     video.setAttribute("src", vids[current_vid]); 
    }); 
    }); 

回答

0

簡單的答案:

  $(document).ready(function(){ 
      var video = document.getElementById('player'); 
      var vids = ["videos/COMBATE-A-TUBERCULOSE.mp4", 
      "videos/Pilula-01.mp4", 
         "http://jell.yfish.us/media/jellyfish-3-mbps-hd-h264.mkv"]; 
      var current_vid = 0; 
      video.volume = 0.2; 
      $('video').on('ended',function(){ 
       current_vid = Math.floor(vids.length); 
       video.setAttribute("src", vids[current_vid]); 
      }); 
      }); 
+0

對不起。它不適合我。看到它:https://jsfiddle.net/Lb5yva8t/ –

相關問題