javascript - Load and shuffle videos each time you enter site -


i've been using boostrap snippet loads video when entering site. http://bootsnipp.com/snippets/featured/ful-screen-video-background

i'm trying make load , randomize list of videos each time enter site, i'm not getting work. me pls!

html:

<section class="content-section video-section"><div class="pattern-overlay"><a id="bgndvideo" class="player" data-property="{videourl:'https://www.youtube.com/watch?v=fdjc1_ibkja',containment:'.video-section', quality:'large', autoplay:true, mute:true, opacity:1}">bg</a></div></section> 

js:

$(document).ready(function () {  $(".player").mb_ytplayer(); }); 

best reagrds.

i keep array of video url's, various options video, select 1 video @ random when page loaded , update data-property of html.

javascript:

var vids = ["https://www.youtube.com/watch?v=fdjc1_ibkja",   "https://www.youtube.com/watch?v=xadzvw9ot3e",   "https://www.youtube.com/watch?v=3wwlhpmqxqi"]; // create list of youtube videos  var currvid = vids[math.floor(math.random()*(vids.length-1))]; // grab random video array.  var opts = { // keep options in object   videourl: currvid, // set video display   containment:'.video-section',   quality:'large',    autoplay:true,    mute:true,    opacity:1 }  $(document).ready(function(){   document.getelementbyid("bgndvideo").dataset.property = json.stringify(opts); // change    $(".player").mb_ytplayer(); // play! }); 

hopefully helps!


Comments