complete main function

This commit is contained in:
cast1e
2024-10-13 23:36:10 +08:00
parent dc5d53a953
commit 5a0769e91b
20 changed files with 482 additions and 71 deletions
+26
View File
@@ -0,0 +1,26 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" href="/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Vite App</title>
<style>
html,body{
width: 100%;
height: 100%;
margin: 0;
padding: 0;
overflow: hidden;
}
#player{
width: 100%;
height: 100%;
}
</style>
</head>
<body>
<video id="player"></video>
<script type="module" src="./playback.ts"></script>
</body>
</html>
+31
View File
@@ -0,0 +1,31 @@
import { invoke } from '@tauri-apps/api/core'
interface Params{
url?:string
}
function getSearchParamsAsObject() {
const params = new URLSearchParams(window.location.search)
const paramsObject = {}
params.forEach((value, key) => {
paramsObject[key] = value
})
return paramsObject
}
const params:Params = getSearchParamsAsObject()
if (params.url) {
console.log(params.url)
invoke('get_file', {
path: params.url
}).then((res) => {
console.log(res)
const binary_data_arr = new Uint8Array(res as number[])
const blob = new Blob([binary_data_arr], { type: 'video/mp4' })
const videoUrl = URL.createObjectURL(blob)
const player = document.getElementById("player") as HTMLVideoElement;
if(player) {
player.src = videoUrl;
player.play();
player.muted = true;
player.loop = true;
}
})
}