|
|
|
@ -1,12 +1,11 @@ |
|
|
|
|
import React, { memo, useRef, useEffect } from 'react'; |
|
|
|
|
import JoLPlayer, { useVideo } from './app'; |
|
|
|
|
import useWindowClient from '@/utils/useWindowClient'; |
|
|
|
|
import React, { memo, useRef, useEffect, useMemo } from 'react'; |
|
|
|
|
import JoLPlayer, { JoLPlayerType } from './app'; |
|
|
|
|
import '@/icons/'; |
|
|
|
|
|
|
|
|
|
const AppComponent = memo(function AppComponent(props) { |
|
|
|
|
const videoRef = useRef<HTMLVideoElement>(null!); |
|
|
|
|
const videoRef = useRef<JoLPlayerType.JoLPlayerRef>(null!); |
|
|
|
|
|
|
|
|
|
const onProgressMouseDown = (val: any) => { |
|
|
|
|
const onProgressMouseDown: JoLPlayerType.callBackType = (val) => { |
|
|
|
|
// console.log(`val`, val);
|
|
|
|
|
}; |
|
|
|
|
const onProgressMouseUp = (val: any) => { |
|
|
|
@ -19,6 +18,9 @@ const AppComponent = memo(function AppComponent(props) { |
|
|
|
|
console.log(`暂停`, val); |
|
|
|
|
}; |
|
|
|
|
const onTimeChange = (val: any) => { |
|
|
|
|
// if (val.currentTime > 50) {
|
|
|
|
|
// videoRef.current.pause();
|
|
|
|
|
// }
|
|
|
|
|
// console.log(`onTimeChange`, val);
|
|
|
|
|
}; |
|
|
|
|
const onEndEd = (val: any) => { |
|
|
|
@ -30,6 +32,35 @@ const AppComponent = memo(function AppComponent(props) { |
|
|
|
|
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) { |
|
|
|
|
setTimeout(() => { |
|
|
|
|
videoRef.current.video.play(); |
|
|
|
|
}, 1000); |
|
|
|
|
|
|
|
|
|
console.log(`object`, videoRef.current.play); |
|
|
|
|
// videoRef.current.play();
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
console.log(`videoRef.current`, videoRef.current); |
|
|
|
|
}, [videoRef.current]); |
|
|
|
|
return ( |
|
|
|
|
<> |
|
|
|
|
<JoLPlayer |
|
|
|
@ -51,6 +82,12 @@ const AppComponent = memo(function AppComponent(props) { |
|
|
|
|
onvolumechange={onvolumechange} |
|
|
|
|
/> |
|
|
|
|
{/* <JoLPlayer /> */} |
|
|
|
|
<button onClick={() => videoMethod('play')}>播放</button> |
|
|
|
|
<button onClick={() => videoMethod('pause')}>暂停</button> |
|
|
|
|
<button onClick={() => videoMethod('load')}>重新加载</button> |
|
|
|
|
<button onClick={() => videoMethod('volume')}>改变声音80</button> |
|
|
|
|
<button onClick={() => videoMethod('seek')}>快进500s</button> |
|
|
|
|
<button onClick={xx}>3333</button> |
|
|
|
|
</> |
|
|
|
|
); |
|
|
|
|
}); |
|
|
|
|