Create Live page for Streams
This commit is contained in:
parent
b1e403e1ea
commit
e4d32bf54e
1 changed files with 34 additions and 0 deletions
34
src/pages/live.astro
Normal file
34
src/pages/live.astro
Normal file
|
@ -0,0 +1,34 @@
|
|||
---
|
||||
// Layout
|
||||
import Base from "@layouts/Default.astro";
|
||||
|
||||
// Environment Variables
|
||||
const DEFAULT_STREAM_PROXY = import.meta.env.DEFAULT_STREAM_PROXY
|
||||
const DEFAULT_STREAM_DATA_PROXY = import.meta.env.DEFAULT_STREAM_DATA_PROXY
|
||||
|
||||
// Components
|
||||
|
||||
// Fetch
|
||||
const Channel = Astro.url.href.split("live?=").pop();
|
||||
const video = await fetch(DEFAULT_STREAM_PROXY + "/api/v1/videos/" + Channel).then((response) => response.json());
|
||||
---
|
||||
|
||||
<Base Title={video.title}>
|
||||
<noscript>
|
||||
<p>In order to watch a live stream on Poke, you'll need JavaScript enabled.</p>
|
||||
</noscript>
|
||||
<div class="video-container">
|
||||
<video id="my_video_1" class="video-js vjs-fluid vjs-default-skin" controls preload="auto"
|
||||
data-setup='{}'>
|
||||
<source src={'https://' + DEFAULT_STREAM_PROXY + '/proxy/stream/' + Channel + '/hls.m3u8'} type="application/x-mpegURL">
|
||||
</video>
|
||||
</div>
|
||||
</Base>
|
||||
<link href="/twitch/video.js/video-js.css" rel="stylesheet">
|
||||
<script is:inline src="/twitch/video.js/video.js"></script>
|
||||
<script src="https://unpkg.com/videojs-contrib-hls/dist/videojs-contrib-hls.js"></script>
|
||||
|
||||
<script is:inline>
|
||||
var player = videojs('my_video_1');
|
||||
player.play();
|
||||
</script>
|
Reference in a new issue