import React, { memo, useRef, useEffect, useMemo, useState } from 'react'; import JoLPlayer, { JoLPlayerType } from '../src/index'; const AppComponent = memo(function AppComponent(props) { const url = useRef( 'https://gs-files.oss-cn-hongkong.aliyuncs.com/okr/test/file/2021/07/01/haiwang.mp4', ); const videoRef = useRef(null!); const onProgressMouseDown: JoLPlayerType.callBackType = (val) => { // console.log(`val`, val); }; const onProgressMouseUp = (val: any) => { console.log(`onProgressMouseUp`, val); }; const onPlay = (val: any) => { console.log(`播放`, val); }; const onPause = (val: any) => { console.log(`暂停`, val); }; const onTimeChange = (val: any) => { // if (val.currentTime > 50) { // videoRef.current.pause(); // } // console.log(`onTimeChange`, val); }; const onEndEd = (val: any) => { // setTimeout(() => { // videoRef.current.setVideoSrc( // 'https://gs-files.oss-accelerate.aliyuncs.com/okr/prod/file/2021/08/10/1628605591454mda-met51bhiqb2sgjzd.mp4', // ); // videoRef.current.play(); // }, 1000); console.log(`onEndEd`, val); }; const onError = () => { console.log(`onError`); }; const onvolumechange = (val: any) => { console.log(`onvolumechange`, val); }; const videoMethod = (status: string) => { if (status === 'play') { videoRef.current.play(); } else if (status === 'pause') { videoRef.current.pause(); } else if (status === 'load') { videoRef.current.load(); } else if (status === 'volume') { videoRef.current.setVolume(86); } else if (status === 'seek') { videoRef.current.seek(500); } }; const xx = () => { console.log(`videoRef.current`, videoRef.current); }; useEffect(() => { if (videoRef.current) { } console.log(`videoRef.current`, videoRef.current); }, [videoRef.current]); const toggle = () => { videoRef.current.setVideoSrc( 'https://gs-files.oss-accelerate.aliyuncs.com/okr/prod/file/2021/08/10/1628605591454mda-met51bhiqb2sgjzd.mp4', ); }; return ( <> ); }); export default AppComponent;