29 lines
1015 B
JavaScript
29 lines
1015 B
JavaScript
/**
|
|
* Initialize Video.js players
|
|
*/
|
|
document.addEventListener('DOMContentLoaded', function() {
|
|
// Find all video.js players
|
|
var videoElements = document.querySelectorAll('.video-js');
|
|
|
|
// Initialize each player with error handling
|
|
videoElements.forEach(function(videoElement) {
|
|
if (videoElement.id) {
|
|
var player = videojs(videoElement.id, {
|
|
// Enable responsive mode
|
|
responsive: true,
|
|
// Provide a default source if none is found
|
|
sources: videoElement.querySelector('source') ? undefined : [
|
|
{ src: '/static/videos/hls/blank/index.m3u8', type: 'application/x-mpegURL' }
|
|
]
|
|
});
|
|
|
|
// Add error handling
|
|
player.on('error', function() {
|
|
var errorDisplay = videoElement.querySelector('.vjs-error-display');
|
|
if (errorDisplay) {
|
|
errorDisplay.innerHTML = '<div class="vjs-modal-dialog-content">Video unavailable or still processing. Please check back later.</div>';
|
|
}
|
|
});
|
|
}
|
|
});
|
|
});
|