Spaces:
Running
Running
File size: 2,035 Bytes
2156c54 3d4392e f42b4a1 2156c54 ac7030c 2156c54 ac7030c 2156c54 ac7030c 2156c54 ac7030c 3d4392e 2156c54 d5b583f 2156c54 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
import { NextResponse, NextRequest } from "next/server"
import { getVideo } from "@/app/api/actions/ai-tube-hf/getVideo"
import { parseMediaProjectionType } from "@/lib/utils/parseMediaProjectionType";
/**
* @deprecated
*/
export async function GET(req: NextRequest) {
const videoId = req.url.split("/").pop() || ""
const video = await getVideo({ videoId, neverThrow: true })
if (!video) {
return new NextResponse("video not found", { status: 404 });
}
const isEquirectangular = parseMediaProjectionType(video) === "equirectangular"
const html = `
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="apple-mobile-web-app-capable" content="yes">
<title>${video.label} - AiTube</title>
<meta name="description" content="${video.description}">
<script src="/aframe/aframe-master.js"></script>
<script src="/aframe/play-on-click.js"></script>
<script src="/aframe/hide-on-play.js"></script>
</head>
<body>
<a-scene>
<a-assets>
<video
id="video"
loop
crossorigin="anonymous"
playsinline
webkit-playsinline
src="${video.assetUrlHd || video.assetUrl}">
</video>
</a-assets>
${
isEquirectangular
? `
<a-videosphere
rotation="0 -90 0"
src="#video"
play-on-click>
</a-videosphere>
` :
`<a-video
src="#video"
width="${
3 // 1024
}" height="${
1.6875 // 576
}"
play-on-click>
</a-video>`
}
<a-camera>
<a-entity
position="0 0 -1.5"
text="align: center;
width: 6;
wrapCount: 100;
color: white;
value: Click or tap to start video"
hide-on-play="#video">
</a-entity>
</a-camera>
</a-scene>
</body>
</html>`
return new NextResponse(html, {
status: 200,
headers: new Headers({ "content-type": "text/html" }),
})
}
|