Well, I have a solution! Joomla rewrites the "src" tag, so I now set it dynamically as follows:
<script>
function loadVideo(videoUrl, videoTitle) {
const videoDisplay = document.querySelector('.video-display');
videoDisplay.innerHTML = '';
const videoPlayer = `
<h3>${videoTitle}</h3>
<video width="100%" height="auto" controls autoplay>
<source data-src="${videoUrl}" type="video/mp4">
</video>
`;
videoDisplay.innerHTML = videoPlayer;
// Set the actual src dynamically
const sourceElement = videoDisplay.querySelector('source');
sourceElement.setAttribute('src', sourceElement.getAttribute('data-src'));
}
</script>