mardi 9 mai 2017

Random playlist video not working. Help. JS Fiddle available

I'm trying to make the playlist random. It seems like something is wrong. The first video plays fine but next one won't play.

This is where the fiddle is located: http://ift.tt/2pg4t7h

<video id="w-video" class="video-js w-video" muted autoplay width=640 height=480>   

</video>
<ul id="playlist">
<li><a href="http://ift.tt/2qVDaeF">Number One</a>
<li><a href="http://ift.tt/1bdkFGf">Number Two</a>
<li><a href="http://ift.tt/2qVHivn">Number Three</a>
</ul>

// Get the playlist from the available URLs on the list 
    playlist = $('#playlist');
    tracks = playlist.find('li a');
    len = tracks.length - 1;
// Select a random item from the list...
    vid = Math.round(Math.random()*len);
// ... and get the href
    vidURL = tracks[vid].href;

//console.log(vid + " " + vidURL)
// Set the source to the selected URL
    $("#w-video").get(0).src = vidURL
// Play the selected URL
    $("#w-video").get(0).play();




Aucun commentaire:

Enregistrer un commentaire