diff --git a/src/assets/core.scss b/src/assets/core.scss index 5a28cde..1263292 100644 --- a/src/assets/core.scss +++ b/src/assets/core.scss @@ -160,8 +160,10 @@ } .video-player{ .video-js{ + @apply w-full h-full; max-width: 100%; max-height: 100%; + background:#fff; // hsl(210, 100%, 48%) } } diff --git a/src/components/video/player.tsx b/src/components/video/player.tsx index e6f399f..99d88d5 100644 --- a/src/components/video/player.tsx +++ b/src/components/video/player.tsx @@ -20,6 +20,7 @@ type StateUpdate = Partial | ((prev: State) => Partial) type Props = { url?: string; cover?: string; showControls?: boolean; className?: string; onChange?: (state: State) => void; + muted?: boolean; } export type PlayerInstance = { play: (url: string, currentTime: number) => void; @@ -47,39 +48,52 @@ export const Player = React.forwardRef((props, ref) => { }) } useEffect(() => { + const playerVideo = document.createElement('video'); + const playerId = `player-container-${Date.now().toString(16)}`; + playerVideo.setAttribute('id', playerId) + playerVideo.setAttribute('preload', 'auto') + playerVideo.setAttribute('playsInline', 'true') + playerVideo.setAttribute('webkit-playsinline', 'true') + if(props.className) playerVideo.setAttribute('className', props.className) + document.querySelector('.video-player-container-inner').appendChild(playerVideo) + + const player = TCPlayer(playerId, { + //sources: [{src: props.url}], + controls: props.showControls, + // muted:props.muted, + autoplay: true, + licenseUrl: 'https://license.vod2.myqcloud.com/license/v2/1328581896_1/v_cube.license' + } + ) + player.on('pause', () => { + setState({playing: false, end: false, error: false}) + }) + player.on('playing', () => { + setState({playing: true, end: false, error: false}) + }) + player.on('ended', () => { + setState({end: true, playing: false, error: false}) + }) + player.on('error', () => { + setState({end: false, playing: false, error: true}) + }) + setTcPlayer(() => player) return () => { - if (tcPlayer) tcPlayer.unload() + if (tcPlayer) { + tcPlayer.pause() + tcPlayer.unload() + } } }, []) React.useImperativeHandle(ref, () => { return { play: (url, currentTime = 0) => { - const player = tcPlayer || TCPlayer( - 'player-container-id', - { - sources: [{src: url}], - controls: false, - licenseUrl: 'https://license.vod2.myqcloud.com/license/v2/1328581896_1/v_cube.license' - } - ) - player.on('pause', () => { - setState({playing: false, end: false, error: false}) - }) - player.on('playing', () => { - setState({playing: true, end: false, error: false}) - }) - player.on('ended', () => { - setState({end: true, playing: false, error: false}) - }) - player.on('error', () => { - setState({end: false, playing: false, error: true}) - }) - if (!tcPlayer) { - setTcPlayer(() => player) - } - if(prevUrl == url){ + console.log('play', url, currentTime) + if (!tcPlayer) return; + const player = tcPlayer + if (prevUrl == url) { player.currentTime(0) - }else{ + } else { player.src(url) } player.play() @@ -92,9 +106,6 @@ export const Player = React.forwardRef((props, ref) => { } }) - return
- + return
}) \ No newline at end of file diff --git a/src/pages/library/components/search-form.tsx b/src/pages/library/components/search-form.tsx index 5835daf..0491ff2 100644 --- a/src/pages/library/components/search-form.tsx +++ b/src/pages/library/components/search-form.tsx @@ -3,44 +3,33 @@ import {useSetState} from "ahooks"; import {PlayCircleOutlined} from "@ant-design/icons"; import {SearchListTimes} from "@/pages/news/components/news-source.ts"; -type SearchParams = { - keywords?: string; - date?: string; -} - type Props = { - onSearch?: (params: SearchParams) => Promise; + onSearch?: (params: VideoSearchParams) => void; onBtnStartClick?: () => Promise; + loading?:boolean; } -export default function SearchForm({onSearch, onBtnStartClick}: Props) { +export default function SearchForm({onSearch, onBtnStartClick,loading}: Props) { const [state, setState] = useSetState<{ - timeRange: string; - keywords: string; - searching: boolean; - time: number; - }>({ - keywords: "", searching: false, timeRange: "", time: 0 - }) - const onFinish = (values: any) => { - setState({searching: true}) + pushing?: boolean; + }>({}) + const onFinish = (values) => { onSearch?.({ - keywords: values.keywords, - date: values.timeRange.join('-'), - }).finally(() => { - setState({searching: false}) + ...values, + pagination: {page: 1, limit: 10} }) + //console.log(values) } return (
-
- - + className={""} layout="inline" onFinish={onFinish} initialValues={{title:'',time_flag:0}}> + + - +