index.js 1.19 KB
Newer Older
1 2 3 4 5 6 7 8 9 10
/*
 * @Title:
 * @Author: hongmye
 * @Date: 2025-03-28 11:18:55
 */
import React, { useState, useEffect, useRef } from 'react';
import { Modal } from 'antd';

import classNames from 'classnames';
import styles from './index.less';
周宏民's avatar
周宏民 committed
11
const videoUrl = 'https://g.civnet.cn:8000/video/companyIntroduction.mp4';
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
const IframeContainer = props => {
  const { loading, isVideoModal, setIsVideoModal } = props;
  const videoRef = useRef(null);

  const width = 1400;

  useEffect(() => {
    if (videoRef.current) {
      if (isVideoModal) {
        videoRef.current.paused && videoRef.current.play();
      } else {
        !videoRef.current.paused && videoRef.current.pause();
      }
    }
  }, [isVideoModal]);
  return (
    <>
      <Modal
        style={{ top: '60px' }}
        wrapClassName={classNames(styles.videoModal, 'demonstration_video_modal')}
        title={null}
        visible={isVideoModal}
        open={isVideoModal}
        footer={null}
        width={width}
        onCancel={() => {
          setIsVideoModal(false);
        }}
      >
        <video ref={videoRef} width={width} autoPlay="autoPlay" muted controls src={videoUrl} loop />
      </Modal>
    </>
  );
};

export default IframeContainer;