@matlo you'll want to use something like hls.js and the HLS manifest URL
@matlo you'll want to use something like hls.js and the HLS manifest URL

Run and edit this code... link here work for anyone else? 


<script>
import Hls from "hls.js";
import { onMount } from "svelte";
export let src;
let videoElement;
let hlsInstance;
// force to 1080p
const targetQualityIndex = 4;
onMount(() => {
if (Hls.isSupported()) {
hlsInstance = new Hls();
hlsInstance.loadSource(src);
hlsInstance.attachMedia(videoElement);
hlsInstance.on(Hls.Events.MANIFEST_PARSED, () => {
// Check if the chosen quality index is valid
console.log(hlsInstance.levels);
if (targetQualityIndex < hlsInstance.levels.length) {
hlsInstance.currentLevel = targetQualityIndex;
}
});
} else if (videoElement.canPlayType("application/vnd.apple.mpegurl")) {
videoElement.src = src;
}
return () => {
if (hlsInstance) {
hlsInstance.destroy();
}
};
});
</script>
<video
bind:this={videoElement}
muted
autoplay
playsinline
loop
class="w-full h-full object-cover"
>
Your browser does not support the video tag.
</video><?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.cloudflare.com/client/v4/accounts/account_identifier/stream",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => "",
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"Tus-Resumable: 1.0.0",
"Upload-Creator: ",
"Upload-Length: ",
"Upload-Metadata: ",
"X-Auth-Email: "
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}CURLOPT_HEADER => true,
CURLOPT_NOBODY => true, if ($err) {
echo "cURL Error #:" . $err;
} else {
// parse response headers from string to array
$response_headers = [];
$response_headers_string = substr($response, 0, strpos($response, "\r\n\r\n"));
foreach (explode("\r\n", $response_headers_string) as $i => $line) {
if ($i === 0) {
$response_headers['http_code'] = $line;
} else {
list ($key, $value) = explode(': ', $line);
$response_headers[$key] = $value;
}
}
$destination = $response_headers["Location"];
return response()
->noContent()
->header('Access-Control-Expose-Headers', 'Location')
->header('Access-Control-Allow-Headers', '*')
->header('Access-Control-Allow-Origin', '*')
->header('Location', $destination);
}