0
Good night, you guys. I found a code here in the stack for random audio playlist and adapted it so that I could run videos, but I’m new to Javascript and I don’t know how to do almost anything. I even need a tutorial suddenly. More complete, of course, because the ones I watched didn’t help me much.
The code below is the playlist code I need. The only problem is that I will run the playlist on a Reveal.js slide and used the autoplaymedia=true configuration. This option allows the video to only load when the slide with the video is displayed. However, javascript cannot load the video automatically but Reveal.js. I need to basically be removed from the script below the option to play automatically as that is what is being done.
/* Objects */
var _player = document.getElementById('player');
/* Aplication */
var tracks = [
'http://media.w3.org/2010/05/sintel/trailer.mp4',
function playNext() {
var track = tracks[Math.floor(Math.random() * tracks.length)];
_player.src = track;
return _player.play();
}
/* Events */
window.addEventListener('load', playNext);
_player.addEventListener('ended', playNext);
Link to codepen (based on the code of Caio Tarifa): Link to codepen
the video has no controls, remove automatic playback as will play later?
– user60252