This commit is contained in:
Boof 2023-06-09 10:12:29 +02:00 committed by GitHub
parent a95df98d2e
commit d5b5213174
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 72 additions and 3 deletions

View File

@ -12,9 +12,9 @@
<body style="background-color: #192127;">
<div style="text-align: center;">
<video id="video" controls width="400">
<source src="https://data.boof.eu.org/Karius og Baktus h264.mp4" />
<source src="https://data.boof.eu.org/Karius og Baktus.webm" />
<source src="https://data.boof.eu.org/Karius og Baktus.ogv" />
<source id="source1" src="https://data.boof.eu.org/Karius og Baktus h264.mp4" />
<source id="source2" src="https://data.boof.eu.org/Karius og Baktus.webm" />
<source id="source3" src="https://data.boof.eu.org/Karius og Baktus.ogv" />
</video>
<br>
<button id="cdn">My cdn</button>

View File

@ -0,0 +1,69 @@
const client = new WebTorrent()
const magnetUri = 'magnet:?xt=urn:btih:08ada5a7a6183aae1e09d831df6748d566095a10&dn=Sintel&tr=udp%3A%2F%2Fexplodie.org%3A6969&tr=udp%3A%2F%2Ftracker.coppersurfer.tk%3A6969&tr=udp%3A%2F%2Ftracker.empire-js.us%3A1337&tr=udp%3A%2F%2Ftracker.leechers-paradise.org%3A6969&tr=udp%3A%2F%2Ftracker.opentrackr.org%3A1337&tr=wss%3A%2F%2Ftracker.btorrent.xyz&tr=wss%3A%2F%2Ftracker.fastcast.nz&tr=wss%3A%2F%2Ftracker.openwebtorrent.com&ws=https%3A%2F%2Fwebtorrent.io%2Ftorrents%2F&xs=https%3A%2F%2Fwebtorrent.io%2Ftorrents%2Fsintel.torrent'
function mp4Vid() {
client.add(magnetUri, (torrent) => {
// Find the video file in the torrent's files
const videoFile = torrent.files.find((file) => file.name.endsWith('.mp4'));
// Create a blob URL from the video file
videoFile.getBlobURL((err, url) => {
if (err) throw err;
// Set the blob URL as the source for the video element
const source = document.getElementById('source1');
source.src = url;
source.type = "video/mp4";
// Load and play the video
const video = document.getElementById('video');
video.load();
video.play();
});
});
}
function webmVid() {
client.add(magnetUri, (torrent) => {
// Find the video file in the torrent's files
const videoFile = torrent.files.find((file) => file.name.endsWith('.webm'));
// Create a blob URL from the video file
videoFile.getBlobURL((err, url) => {
if (err) throw err;
// Set the blob URL as the source for the video element
const source = document.getElementById('source2');
source.src = url;
source.type = "video/webm";
// Load and play the video
const video = document.getElementById('video');
video.load();
video.play();
});
});
}
function oggVid() {
client.add(magnetUri, (torrent) => {
// Find the video file in the torrent's files
const videoFile = torrent.files.find((file) => file.name.endsWith('.ogv'));
// Create a blob URL from the video file
videoFile.getBlobURL((err, url) => {
if (err) throw err;
// Set the blob URL as the source for the video element
const source = document.getElementById('source3');
source.src = url;
source.type = "video/ogg";
// Load and play the video
const video = document.getElementById('video');
video.load();
video.play();
});
});
}