Nhảy tới nội dung

CameraContext.isUsing

Bắt đầu hỗ trợ ở phiên bản:

  • SDK: 2.39.0

Kiểm tra trạng thái streaming

import React, { useEffect, useRef } from "react";
import { Box, Page } from "zmp-ui";
import api, { FacingMode, ZMACamera } from "zmp-sdk";

const HomePage = () => {
const videoRef = useRef < HTMLVideoElement > null;
useEffect(() => {
const videoElement = videoRef.current;
if (!videoElement) {
console.log("Media component not ready");
return;
}
const camera = api.createCameraContext({
videoElement: videoElement,
mediaConstraints: {
width: 640,
height: 480,
facingMode: FacingMode.BACK,
audio: false,
},
});

const isUsing = camera.isUsing();
}, []);

return (
<Page>
<Box>
<video
style={{ width: "100vw", height: "auto" }}
ref={videoRef}
muted
playsInline
webkit-playsinline
/>
</Box>
</Page>
);
};

export default HomePage;