Skip to content

Commit 97128e7

Browse files
committed
Add example hls.js player and update README.md. Updated static serving in nginx.conf.
1 parent 19265b1 commit 97128e7

File tree

4 files changed

+66
-11
lines changed

4 files changed

+66
-11
lines changed

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,10 @@ volumes:
6262
* Stream Key: `hello`
6363

6464
### Watch Stream
65-
* In Safari, VLC or any HLS player, open:
65+
* Load up the example hls.js player in your browser:
66+
http://localhost:8080/player/?url=http://localhost:8080/live/hello.m3u8
67+
68+
* Or in Safari, VLC or any HLS player, open:
6669
```
6770
http://localhost:8080/live/$STREAM_NAME.m3u8
6871
```

nginx-cuda.conf

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ rtmp {
4141
}
4242

4343
http {
44+
root /www/static;
4445
access_log /dev/stdout combined;
4546

4647
ssl_ciphers HIGH:!aNULL:!MD5;
@@ -80,15 +81,14 @@ http {
8081

8182
location /stat {
8283
rtmp_stat all;
83-
rtmp_stat_stylesheet static/stat.xsl;
84+
rtmp_stat_stylesheet stat.xsl;
8485
}
8586

86-
location /static {
87-
alias /www/static;
87+
location /stat.xsl {
88+
root /www/static;
8889
}
8990

90-
location = /crossdomain.xml {
91-
root /www/static;
91+
location /crossdomain.xml {
9292
default_type text/xml;
9393
expires 24h;
9494
}

nginx.conf

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ rtmp {
4141
}
4242

4343
http {
44+
root /www/static;
4445
access_log /dev/stdout combined;
4546

4647
ssl_ciphers HIGH:!aNULL:!MD5;
@@ -80,15 +81,14 @@ http {
8081

8182
location /stat {
8283
rtmp_stat all;
83-
rtmp_stat_stylesheet static/stat.xsl;
84+
rtmp_stat_stylesheet stat.xsl;
8485
}
8586

86-
location /static {
87-
alias /www/static;
87+
location /stat.xsl {
88+
root /www/static;
8889
}
8990

90-
location = /crossdomain.xml {
91-
root /www/static;
91+
location /crossdomain.xml {
9292
default_type text/xml;
9393
expires 24h;
9494
}

static/player/index.html

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
2+
<!DOCTYPE html>
3+
<html lang="en">
4+
<head>
5+
<meta charset="utf-8">
6+
<title>hls.js Player</title>
7+
<script src="https://cdn.jsdelivr.net/npm/hls.js@latest"></script>
8+
<style>
9+
.container {
10+
width: 80%;
11+
margin: 0 auto;
12+
}
13+
14+
.video-wrapper {
15+
padding-top: 20px;
16+
height: 80%;
17+
margin: 0 auto;
18+
}
19+
20+
video {
21+
display: block;
22+
width: 100%;
23+
height: 100%;
24+
}
25+
</style>
26+
</head>
27+
<body>
28+
<div class="container">
29+
<h1>hls.js player</h1>
30+
<a href="https://github.com/video-dev/hls.js">github.com/video-dev/hls.js</a>
31+
<div class="video-wrapper">
32+
<video id="video" controls muted></video>
33+
</div>
34+
</div>
35+
36+
<script>
37+
var params = new URLSearchParams(window.location.search);
38+
var url = params.get('url');
39+
if (Hls.isSupported()) {
40+
var video = document.getElementById('video');
41+
var hls = new Hls();
42+
hls.attachMedia(video);
43+
hls.on(Hls.Events.MEDIA_ATTACHED, function () {
44+
hls.loadSource(url);
45+
hls.on(Hls.Events.MANIFEST_PARSED, function (event, data) {
46+
video.play();
47+
});
48+
});
49+
}
50+
</script>
51+
</body>
52+
</html>

0 commit comments

Comments
 (0)