master
parent
285992f38d
commit
77377c9acf
11 changed files with 135 additions and 37 deletions
@ -0,0 +1,115 @@ |
|||||||
|
import React, { memo, useRef, useEffect, useMemo, useState } from 'react'; |
||||||
|
import JoLPlayer, { JoLPlayerType } from '../src/index'; |
||||||
|
|
||||||
|
const AppComponent = memo(function AppComponent(props) { |
||||||
|
const url = useRef<string>( |
||||||
|
'https://gs-files.oss-cn-hongkong.aliyuncs.com/okr/test/file/2021/07/01/haiwang.mp4', |
||||||
|
); |
||||||
|
const videoRef = useRef<JoLPlayerType.JoLPlayerRef>(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 ( |
||||||
|
<> |
||||||
|
<JoLPlayer |
||||||
|
ref={videoRef} |
||||||
|
option={{ |
||||||
|
videoSrc: url.current, |
||||||
|
width: 750, |
||||||
|
height: 420, |
||||||
|
theme: '#00D3FF', |
||||||
|
poster: 'https://cdn.gudsen.com/2021/06/28/f81356b08b4842d7a3719499f557c8e4.JPG', |
||||||
|
language: 'en', |
||||||
|
}} |
||||||
|
onProgressMouseDown={onProgressMouseDown} |
||||||
|
onPlay={onPlay} |
||||||
|
onPause={onPause} |
||||||
|
onTimeChange={onTimeChange} |
||||||
|
onEndEd={onEndEd} |
||||||
|
onProgressMouseUp={onProgressMouseUp} |
||||||
|
onError={onError} |
||||||
|
onvolumechange={onvolumechange} |
||||||
|
/> |
||||||
|
<JoLPlayer |
||||||
|
option={{ |
||||||
|
videoSrc: |
||||||
|
'https://gs-files.oss-accelerate.aliyuncs.com/okr/prod/file/2021/08/10/1628605591454mda-met51bhiqb2sgjzd.mp4', |
||||||
|
width: 500, |
||||||
|
height: 320, |
||||||
|
theme: 'red', |
||||||
|
poster: 'https://cdn.gudsen.com/2021/06/28/f81356b08b4842d7a3719499f557c8e4.JPG', |
||||||
|
pausePlacement: 'center', |
||||||
|
}} |
||||||
|
/> |
||||||
|
<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> |
||||||
|
<button onClick={toggle}>切换播放视频路劲</button> |
||||||
|
</> |
||||||
|
); |
||||||
|
}); |
||||||
|
|
||||||
|
export default AppComponent; |
@ -0,0 +1,4 @@ |
|||||||
|
import React from 'react'; |
||||||
|
import ReactDOM from 'react-dom'; |
||||||
|
import App from './appComponent'; |
||||||
|
ReactDOM.render(<App />, document.getElementById('root')); |
Before Width: | Height: | Size: 4.2 KiB |
@ -1,15 +0,0 @@ |
|||||||
{ |
|
||||||
"short_name": "React App", |
|
||||||
"name": "Create React App Sample", |
|
||||||
"icons": [ |
|
||||||
{ |
|
||||||
"src": "favicon.ico", |
|
||||||
"sizes": "64x64 32x32 24x24 16x16", |
|
||||||
"type": "image/x-icon" |
|
||||||
} |
|
||||||
], |
|
||||||
"start_url": ".", |
|
||||||
"display": "standalone", |
|
||||||
"theme_color": "#000000", |
|
||||||
"background_color": "#ffffff" |
|
||||||
} |
|
@ -1,6 +0,0 @@ |
|||||||
import { useVideo } from '@/core/useVideo'; |
|
||||||
import * as JoLPlayerType from '@/interface'; |
|
||||||
import JoLPlayer from '@/core/index'; |
|
||||||
export { useVideo }; |
|
||||||
export { JoLPlayerType }; |
|
||||||
export default JoLPlayer; |
|
@ -0,0 +1,4 @@ |
|||||||
|
import React from 'react'; |
||||||
|
import ReactDOM from 'react-dom'; |
||||||
|
import App from './appComponent'; |
||||||
|
ReactDOM.render(<App />, document.getElementById('root')); |
@ -1,4 +1,5 @@ |
|||||||
import React from 'react'; |
import * as JoLPlayerType from '@/interface'; |
||||||
import ReactDOM from 'react-dom'; |
import JoLPlayer from '@/core/index'; |
||||||
import App from './appComponent'; |
import '@/icons/'; |
||||||
ReactDOM.render(<App />, document.getElementById('root')); |
export { JoLPlayerType }; |
||||||
|
export default JoLPlayer; |
||||||
|
Loading…
Reference in new issue