Update README
This commit is contained in:
parent
30228bb4a4
commit
81e48040ee
90
README.md
90
README.md
|
@ -49,6 +49,7 @@ rtmp {
|
||||||
|
|
||||||
hls on;
|
hls on;
|
||||||
hls_path /mnt/ssd_data/hls/src;
|
hls_path /mnt/ssd_data/hls/src;
|
||||||
|
hls_continuous off;
|
||||||
hls_fragment 1s;
|
hls_fragment 1s;
|
||||||
hls_fragment_naming system;
|
hls_fragment_naming system;
|
||||||
hls_playlist_length 60s;
|
hls_playlist_length 60s;
|
||||||
|
@ -113,35 +114,84 @@ WantedBy=multi-user.target
|
||||||
### VideoJS Player example code
|
### VideoJS Player example code
|
||||||
|
|
||||||
```
|
```
|
||||||
<link href="https://unpkg.com/video.js/dist/video-js.min.css" rel="stylesheet" />
|
<!DOCTYPE html>
|
||||||
<style>
|
<html>
|
||||||
html,
|
<head>
|
||||||
body {
|
<meta charset='utf-8'>
|
||||||
|
<meta http-equiv="X-UA-Compatible" content="chrome=1">
|
||||||
|
<link href="/lib/video-js.min.css" rel="stylesheet" />
|
||||||
|
<title>Player - chaos.stream</title>
|
||||||
|
<style>
|
||||||
|
html, body, #wrapper {
|
||||||
margin: 0;
|
margin: 0;
|
||||||
padding: 0;
|
padding: 0;
|
||||||
}
|
width: 100%;
|
||||||
</style>
|
height: 100%;
|
||||||
<div>
|
}
|
||||||
<video id='hls-player' class="video-js vjs-default-skin vjs-big-play-centered" controls>
|
</style>
|
||||||
<source type="application/x-mpegURL" src="https://cdn.chaos.stream/hls/<?php echo $_GET["profile"]."/".$_GET["stream"]; ?>.m3u8">
|
</head>
|
||||||
</video>
|
<body>
|
||||||
</div>
|
<div id="wrapper">
|
||||||
<script src="https://unpkg.com/video.js/dist/video.min.js"></script>
|
<video id='hls-player' class="video-js vjs-default-skin vjs-big-play-centered" controls autoplay>
|
||||||
<script>
|
<source type="application/x-mpegURL">
|
||||||
var player = videojs('hls-player', {liveui: true});
|
</video>
|
||||||
player.fill(true);
|
</div>
|
||||||
</script>
|
<script src="/lib/video.min.js"></script>
|
||||||
|
<script>
|
||||||
|
document.querySelector('source').src = 'https://cdn.chaos.stream/hls/src/' + window.location.pathname.substring(1) + '.m3u8';
|
||||||
|
document.getElementById("hls-player").addEventListener("error",function(event){
|
||||||
|
console.log('HTML5 video error, reloading page in 10sec');
|
||||||
|
setTimeout(function () { location.reload(true); }, 10000);
|
||||||
|
});
|
||||||
|
|
||||||
|
var player = videojs('hls-player', {
|
||||||
|
liveui: true,
|
||||||
|
html5: {
|
||||||
|
vhs: {
|
||||||
|
blacklistDuration: Infinity,
|
||||||
|
maxPlaylistRetries: 5,
|
||||||
|
experimentalBufferBasedABR: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
player.ready(function() {
|
||||||
|
let player = this
|
||||||
|
|
||||||
|
player.on("error", function(){
|
||||||
|
console.log('VJS Error. Treating as offline.');
|
||||||
|
player.poster('https://live.on.chaos.stream/lib/offline.png');
|
||||||
|
player.errorDisplay.hide();
|
||||||
|
});
|
||||||
|
|
||||||
|
player.on("ended", function(){
|
||||||
|
console.log('Stream ended. Redirecting to profile.');
|
||||||
|
document.location = 'https://chaos.stream/profile/' + window.location.pathname.substring(1);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
player.fill(true);
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
```
|
```
|
||||||
|
|
||||||
### accompanying nginx config for VideoJS Player
|
### accompanying nginx config for VideoJS Player
|
||||||
|
|
||||||
```
|
```
|
||||||
location ~ ^/(.+)/(.+)$ {
|
location = /favicon.ico {
|
||||||
rewrite ^/(.+)/(.+)$ /watch.php?stream=$1&profile=$2 last;
|
#ignore rewrite rules
|
||||||
}
|
}
|
||||||
|
|
||||||
location ~ ^/(.+)$ {
|
location ^~ /lib/ {
|
||||||
rewrite ^/(.+)$ /watch.php?stream=$1&profile=src last;
|
#ignore rewrite rules
|
||||||
}
|
}
|
||||||
|
|
||||||
|
location = /watch.html {
|
||||||
|
#ignore rewrite rules
|
||||||
|
}
|
||||||
|
|
||||||
|
location / {
|
||||||
|
rewrite / /watch.html last;
|
||||||
|
}
|
||||||
```
|
```
|
||||||
|
|
Loading…
Reference in a new issue