import { Connect } from "@cqsjjb/jjb-dva-runtime";
import { useEffect, useState } from "react";
import AliPlayer from "zy-react-library/components/Video/AliPlayer";
import { NS_BI_MARK_INFO } from "~/enumerate/namespace";

const VideoPlay = (props) => {
  const [playUrl, setPlayUrl] = useState("");

  const getData = async () => {
    const { data, success } = await props.getFixedCameraPlayUrl({ indexCode: props.cameraNumber });
    if (success && data)
      setPlayUrl(data.url);
  };

  useEffect(() => {
    getData();
  }, []);

  return (
    <div>
      {playUrl
        ? (
            <AliPlayer source={playUrl} height="500px" isLive />
          )
        : (
            <div style={{ color: "#fff", textAlign: "center" }}>暂无视频</div>
          )}
    </div>
  );
};

export default Connect([NS_BI_MARK_INFO], true)(VideoPlay);
