mirror of
https://github.com/zedeus/nitter.git
synced 2024-06-09 00:29:22 +00:00
Make hls playback work without inline JS
This commit is contained in:
parent
4120558649
commit
7749c754bc
|
@ -1,25 +1,30 @@
|
||||||
// @license http://www.gnu.org/licenses/agpl-3.0.html AGPL-3.0
|
// @license http://www.gnu.org/licenses/agpl-3.0.html AGPL-3.0
|
||||||
// SPDX-License-Identifier: AGPL-3.0-only
|
// SPDX-License-Identifier: AGPL-3.0-only
|
||||||
function playVideo(overlay) {
|
const video_overlay = document.getElementsByClassName("video-overlay");
|
||||||
const video = overlay.parentElement.querySelector('video');
|
|
||||||
const url = video.getAttribute("data-url");
|
|
||||||
video.setAttribute("controls", "");
|
|
||||||
overlay.style.display = "none";
|
|
||||||
|
|
||||||
if (Hls.isSupported()) {
|
for (var i = 0 ; i < video_overlay.length; i++) {
|
||||||
var hls = new Hls({autoStartLoad: false});
|
video_overlay[i].addEventListener('click', function () {
|
||||||
hls.loadSource(url);
|
|
||||||
hls.attachMedia(video);
|
const video = this.parentElement.querySelector('video');
|
||||||
hls.on(Hls.Events.MANIFEST_PARSED, function () {
|
const url = video.getAttribute("data-url");
|
||||||
hls.loadLevel = hls.levels.length - 1;
|
video.setAttribute("controls", "");
|
||||||
hls.startLoad();
|
this.style.display = "none";
|
||||||
video.play();
|
|
||||||
});
|
if (Hls.isSupported()) {
|
||||||
} else if (video.canPlayType('application/vnd.apple.mpegurl')) {
|
var hls = new Hls({autoStartLoad: false});
|
||||||
video.src = url;
|
hls.loadSource(url);
|
||||||
video.addEventListener('canplay', function() {
|
hls.attachMedia(video);
|
||||||
video.play();
|
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;
|
||||||
|
video.addEventListener('canplay', function() {
|
||||||
|
video.play();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
// @license-end
|
// @license-end
|
||||||
|
|
|
@ -109,7 +109,7 @@ proc renderVideo*(video: Video; prefs: Prefs; path: string): VNode =
|
||||||
source(src=source, `type`="video/mp4")
|
source(src=source, `type`="video/mp4")
|
||||||
of m3u8, vmap:
|
of m3u8, vmap:
|
||||||
video(poster=thumb, data-url=source, data-autoload="false", muted=prefs.muteVideos)
|
video(poster=thumb, data-url=source, data-autoload="false", muted=prefs.muteVideos)
|
||||||
verbatim "<div class=\"video-overlay\" onclick=\"playVideo(this)\">"
|
verbatim "<div class=\"video-overlay\">"
|
||||||
tdiv(class="overlay-circle"): span(class="overlay-triangle")
|
tdiv(class="overlay-circle"): span(class="overlay-triangle")
|
||||||
verbatim "</div>"
|
verbatim "</div>"
|
||||||
if container.len > 0:
|
if container.len > 0:
|
||||||
|
|
Loading…
Reference in a new issue