53 lines
1.4 KiB
HTML
53 lines
1.4 KiB
HTML
<!doctype html>
|
|
<html lang="zh">
|
|
<head>
|
|
<meta charset="utf-8" />
|
|
<title>测试应用</title>
|
|
<style>
|
|
body {
|
|
padding: 0;
|
|
margin: 0;
|
|
}
|
|
li {
|
|
display: block;
|
|
}
|
|
#main {
|
|
display: flex;
|
|
}
|
|
</style>
|
|
</head>
|
|
|
|
<body>
|
|
<header></header>
|
|
<p>1111111111111</p>
|
|
<main id="main">
|
|
<video id="localVideo" autoplay muted></video>
|
|
</main>
|
|
<footer></footer>
|
|
<script>
|
|
// 初始化MediaSource ;aiortc 采集的帧转换为 Base64 图片流;用 MediaSource 拼接帧数据
|
|
async function initMediaSource() {
|
|
mediaSource = await window.pywebview.api.fetch_media();
|
|
videoEl.src = URL.createObjectURL(mediaSource);
|
|
mediaSource.addEventListener("sourceopen", () => {
|
|
sourceBuffer = mediaSource.addSourceBuffer(
|
|
'video/mp4; codecs="avc1.42E01E"',
|
|
);
|
|
sourceBuffer.mode = "sequence";
|
|
});
|
|
}
|
|
const localVideo = document.getElementById("localVideo");
|
|
localVideo.srcObject = callPythonFetchMedia();
|
|
|
|
/**
|
|
* 供 Python 调用的 JS 函数
|
|
* window.evaluate_js(f'js_receive_python_msg("msg")')
|
|
*/
|
|
function js_receive_python_msg(msg) {
|
|
console.info(`[JS] 收到 Python 消息:${msg}`);
|
|
}
|
|
</script>
|
|
<script type="module" src="module/main.js"></script>
|
|
</body>
|
|
</html>
|