Spaces:
Sleeping
Sleeping
<html> | |
<head> | |
<title>Page title in index.html</title> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1" /> | |
</head> | |
<body> | |
<h1>It works!</h1> | |
<button onclick="testDownload()">Test file download</button> | |
<button onclick="testCamera()">Test camera</button> | |
<button onclick="testMicrophone()">Test microphone</button> | |
<button onclick="window.close()">window.close()</button> | |
<script> | |
const testDownload = async () => { | |
const blob = new Blob([ | |
new Uint8Array("Hello, world!".split("").map(i => i.charCodeAt(0))) | |
], { | |
type: "text/plain" | |
}); | |
ExternalDownloadHelper.download("test.txt", blob); | |
}; | |
const testCamera = async () => { | |
const stream = await navigator.mediaDevices.getUserMedia({ | |
video: true | |
}); | |
const video = document.createElement("video"); | |
video.srcObject = stream; | |
video.autoplay = true; | |
video.controls = true; | |
document.body.appendChild(video); | |
}; | |
const testMicrophone = async () => { | |
const stream = await navigator.mediaDevices.getUserMedia({ | |
audio: true | |
}); | |
const audio = document.createElement("audio"); | |
audio.srcObject = stream; | |
audio.autoplay = true; | |
audio.controls = true; | |
document.body.appendChild(audio); | |
}; | |
</script> | |
</body> | |
</html> | |