diff --git a/src/components/video/player.tsx b/src/components/video/player.tsx index 99d88d5..f77b57c 100644 --- a/src/components/video/player.tsx +++ b/src/components/video/player.tsx @@ -19,6 +19,7 @@ type StateUpdate = Partial | ((prev: State) => Partial) type Props = { url?: string; cover?: string; showControls?: boolean; className?: string; + poster?: string; onChange?: (state: State) => void; muted?: boolean; } @@ -47,6 +48,13 @@ export const Player = React.forwardRef((props, ref) => { return _state }) } + + useEffect(()=>{ + if(props.url && tcPlayer){ + tcPlayer.src(props.url) + } + },[props.url, tcPlayer]) + useEffect(() => { const playerVideo = document.createElement('video'); const playerId = `player-container-${Date.now().toString(16)}`; @@ -61,6 +69,7 @@ export const Player = React.forwardRef((props, ref) => { //sources: [{src: props.url}], controls: props.showControls, // muted:props.muted, + poster: props.poster, autoplay: true, licenseUrl: 'https://license.vod2.myqcloud.com/license/v2/1328581896_1/v_cube.license' } diff --git a/src/pages/library/components/video-detail.tsx b/src/pages/library/components/video-detail.tsx index bc5a68b..782752a 100644 --- a/src/pages/library/components/video-detail.tsx +++ b/src/pages/library/components/video-detail.tsx @@ -1,42 +1,88 @@ -import {Button, Modal} from "antd"; - +import {Button, Input, Modal} from "antd"; +import {saveAs} from "file-saver"; +import {useEffect, useState} from "react"; +import {useSetState} from "ahooks"; import {Player} from "@/components/video/player.tsx"; import ArticleGroup from "@/components/article/group"; +import * as article from "@/service/api/article.ts"; +import {push2room} from "@/service/api/video.ts"; +import {showErrorToast, showToast} from "@/components/message.ts"; type Props = { video?: VideoInfo; onClose?: () => void } export default function VideoDetail({video, onClose}: Props) { - const startStream = () => { + const [groups, setGroups] = useState([]); + + const [state, setState] = useSetState({ + exporting: false, + pushing: false, + }) + // 将视频推送到数字人直播间 + const pushToRoom = () => { + if (video) { + if (state.pushing) return + setState({pushing: true}) + push2room([video.id]).then(() => { + showToast('一键推流成功,已推流至数字人直播间,请查看!', 'success') + }).catch(showErrorToast).finally(() => { + setState({pushing: false}) + }) + } } + // 下载视频 const downloadVideo = () => { + if (video?.oss_video_url) { + const filename = video.oss_video_url.split('/').pop() || `${video.id}.flv` + saveAs(video.oss_video_url, filename) + } } + useEffect(() => { + if (video) { + if (video.id > 0) { + article.getById(video.id).then(res => { + setGroups(res.content_group) + }) + } + } + }, [video]) + return (<>
-
- +
+
创建时间: 5小时前
-
- 标题: xxxxxxxx +
新闻内容
+
+ 标题 + + +
-
- +
+
+ 正文 +
+
+ +
- +
diff --git a/src/pages/library/index.tsx b/src/pages/library/index.tsx index 8d89c55..d054983 100644 --- a/src/pages/library/index.tsx +++ b/src/pages/library/index.tsx @@ -86,6 +86,6 @@ export default function LibraryIndex() {
- setDetailVideo(undefined)}/> + {detailVideo && setDetailVideo(undefined)}/>} ) } \ No newline at end of file diff --git a/src/pages/news/components/button-push2video.tsx b/src/pages/news/components/button-push2video.tsx index 42904e8..b6b34b7 100644 --- a/src/pages/news/components/button-push2video.tsx +++ b/src/pages/news/components/button-push2video.tsx @@ -4,12 +4,13 @@ import {showErrorToast, showToast} from "@/components/message.ts"; import {push2video} from "@/service/api/article.ts"; -export default function ButtonPush2Video(props: { ids: Id[] }) { +export default function ButtonPush2Video(props: { ids: Id[];onSuccess?:()=>void; }) { const [loading, setLoading] = useState(false) const handlePush = () => { setLoading(true) push2video(props.ids).then(() => { showToast('一键推流成功,已成功推入数字人视频生成,请前往数字人视频生成页面查看!', 'success') + props.onSuccess?.() }).catch(showErrorToast).finally(() => { setLoading(false) }) diff --git a/src/pages/news/edit.tsx b/src/pages/news/edit.tsx index 2222a21..e18f6c4 100644 --- a/src/pages/news/edit.tsx +++ b/src/pages/news/edit.tsx @@ -89,7 +89,7 @@ export default function NewEdit() { pagination: {page, limit: 10} }))} /> - +
}
来源: {item.media_name}
{/**/} -
发布时间: {item.publish_time}
+
发布时间: {formatTime(item.publish_time)}
diff --git a/src/pages/video/index.tsx b/src/pages/video/index.tsx index 20cf44b..5691b74 100644 --- a/src/pages/video/index.tsx +++ b/src/pages/video/index.tsx @@ -45,9 +45,9 @@ export default function VideoIndex() { // 播放视频 const playVideo = (video: VideoInfo, playingIndex: number) => { - if (video.status !== 1) { // video.oss_video_url && + if (video.oss_video_url && video.status !== 1) { setState({playingIndex}) - player.current?.play(video.oss_video_url||'https://staticplus.gachafun.com/ai-collect/composite_video/2024-12-14/1185251497659736064.flv', 0) + player.current?.play(video.oss_video_url, 0) } } // 处理全选