ShowerLoop-cc/docker/showerloop/public/static/js/videojs-player.min.js

37 lines
1.2 KiB
JavaScript

document.addEventListener("DOMContentLoaded", function() {
// Initialize non-video-js videos
const nonVideoJsVideos = document.querySelectorAll("video:not(.video-js)");
if (nonVideoJsVideos.length) {
nonVideoJsVideos.forEach(function(video) {
const videoId = video.id || "video-" + Math.floor(Math.random() * 1000000);
video.id = videoId;
video.classList.add("video-js");
video.classList.add("vjs-big-play-centered");
// Check if player is already initialized
if (!videojs.getPlayers()[videoId]) {
videojs(videoId, {
controls: true,
autoplay: false,
preload: "auto"
});
}
});
}
// Initialize video-js videos that don't have data-setup attribute
const videoJsVideos = document.querySelectorAll("video.video-js:not([data-setup])");
videoJsVideos.forEach(function(video) {
const videoId = video.id;
// Check if player is already initialized
if (videoId && !videojs.getPlayers()[videoId]) {
videojs(videoId, {
controls: true,
autoplay: false,
preload: "auto"
});
}
});
// Don't re-initialize videos that already have data-setup attribute
// as they will be automatically initialized by Video.js
});