Skip to content

Commit

Permalink
enabling videos to autoplay
Browse files Browse the repository at this point in the history
  • Loading branch information
mmaterman committed Jun 13, 2024
1 parent b4d1ba7 commit c90d7e2
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
<!-- <script src="https://vjs.zencdn.net/ie8/1.1.2/videojs-ie8.min.js"></script> -->
</head>
<style>
/* Additional styles to enhance appearance */
body {
background: #091F2F;
text-align: center;
Expand Down Expand Up @@ -42,21 +41,18 @@
const videoContainer = document.getElementById('my_video_1');
const videoSources = [
{ src: "https://www.tutorialspoint.com/videos/sample1080p.mp4", type: "video/mp4" },
{ src: "https://www.tutorialspoint.com/videos/video1.mp4", type: "video/mp4" }
{ src: "https://www.tutorialspoint.com/videos/video1.mp4", type: "video/mp4" },
{ src: "https://media.w3.org/2010/05/sintel/trailer.mp4", type: "video/mp4" },
];

let currentVideoIndex = 0;

function playNextVideo() {
const randomIndex = Math.floor(Math.random() * videoSources.length);
const videoSource = videoSources[randomIndex];

const player = videojs(videoContainer, { controls: true, loop: false });
const player = videojs(videoContainer, { controls: false, autoplay: true, muted: true, loop: false, inactivityTimeout: 0 });
player.src({ src: videoSource.src, type: videoSource.type });
player.play();

currentVideoIndex++;

player.on('ended', function() {
playNextVideo();
});
Expand Down

0 comments on commit c90d7e2

Please sign in to comment.