mirror of
https://github.com/bytedream/stream-bypass.git
synced 2025-06-27 18:40:31 +02:00
Added native m3u8 / hls streaming
This commit is contained in:
14
src/res/hls.html
Normal file
14
src/res/hls.html
Normal file
@ -0,0 +1,14 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<!--I haven't found out how to include scripts from third party websites, if even possible. PRs are always welcome-->
|
||||
<script src="https://cdn.jsdelivr.net/npm/hls.js@latest"></script>
|
||||
<link rel="stylesheet" href="/res/hls.css">
|
||||
<title>m3u8</title>
|
||||
</head>
|
||||
<body style="margin: 0">
|
||||
<video id="video" style="width: 100%; height: 100%"></video>
|
||||
<p id="not-supported" hidden>Filed to play m3u8 video. Try again or create a new issue <a href="https://github.com/ByteDream/stream-bypass/issues">here</a></p>
|
||||
<script src="/res/hls.js"></script>
|
||||
</body>
|
||||
</html>
|
6
src/res/hls.sass
Normal file
6
src/res/hls.sass
Normal file
@ -0,0 +1,6 @@
|
||||
html, body, video
|
||||
height: 100%
|
||||
width: 100%
|
||||
|
||||
video
|
||||
margin: auto
|
20
src/res/hls.ts
Normal file
20
src/res/hls.ts
Normal file
@ -0,0 +1,20 @@
|
||||
function loadHls() {
|
||||
let url = window.location.hash.substring(1)
|
||||
let video = document.getElementById('video') as HTMLVideoElement;
|
||||
|
||||
video.controls = true
|
||||
if (video.canPlayType('application/vnd.apple.mpegurl')) {
|
||||
video.src = url
|
||||
// @ts-ignore
|
||||
} else if (Hls.isSupported()) {
|
||||
// @ts-ignore
|
||||
let hls = new Hls()
|
||||
hls.loadSource(url)
|
||||
hls.attachMedia(video)
|
||||
} else {
|
||||
// shows a message if hls is not supported
|
||||
document.getElementById('not-supported').hidden = false
|
||||
}
|
||||
}
|
||||
|
||||
loadHls()
|
Reference in New Issue
Block a user