2022-05-27 07:48:57 +00:00
|
|
|
(function () {
|
|
|
|
function loadVideo() {
|
|
|
|
// Get video div element
|
|
|
|
let videoDivEl = document.getElementById('video')
|
|
|
|
|
|
|
|
// External Video URL
|
|
|
|
let videoUrl = videoDivEl.dataset.url
|
|
|
|
|
|
|
|
// Create video element
|
|
|
|
let videoEl = document.createElement('video')
|
|
|
|
videoEl.controls = true
|
|
|
|
videoEl.classList.add('fw')
|
|
|
|
|
|
|
|
// Load video
|
|
|
|
if (Hls.isSupported()) {
|
|
|
|
let hls = new Hls()
|
|
|
|
hls.loadSource(videoUrl)
|
|
|
|
hls.attachMedia(videoEl)
|
|
|
|
} else if (videoEl.canPlayType('application/vnd.apple.mpegurl')) {
|
|
|
|
videoEl.src = videoUrl
|
|
|
|
}
|
|
|
|
|
|
|
|
// Add video element
|
|
|
|
videoDivEl.appendChild(videoEl)
|
|
|
|
}
|
|
|
|
|
|
|
|
// JS
|
|
|
|
let script = document.createElement('script')
|
2022-10-22 18:33:46 +00:00
|
|
|
script.src = '/-/hlsjs/hls.js?v=1.2.4'
|
2022-05-27 07:48:57 +00:00
|
|
|
script.onload = loadVideo
|
|
|
|
document.head.appendChild(script)
|
|
|
|
})()
|