nitter/public/js/hlsPlayback.js

25 lines
809 B
JavaScript
Raw Normal View History

// @license http://www.gnu.org/licenses/agpl-3.0.html AGPL-3.0
2019-08-19 18:25:00 +00:00
function playVideo(overlay) {
const video = overlay.parentElement.querySelector('video');
2019-11-18 17:26:48 +00:00
const url = video.getAttribute("data-url");
2019-08-19 18:25:00 +00:00
video.setAttribute("controls", "");
overlay.style.display = "none";
2019-11-18 17:26:48 +00:00
if (Hls.isSupported()) {
var hls = new Hls({autoStartLoad: false});
hls.loadSource(url);
hls.attachMedia(video);
hls.on(Hls.Events.MANIFEST_PARSED, function () {
hls.loadLevel = hls.levels.length - 1;
hls.startLoad();
video.play();
});
} else if (video.canPlayType('application/vnd.apple.mpegurl')) {
video.src = url;
2021-12-26 22:49:51 +00:00
video.addEventListener('canplay', function() {
2019-11-18 17:26:48 +00:00
video.play();
});
}
2019-08-19 18:25:00 +00:00
}
// @license-end