updated
This commit is contained in:
parent
9c90ffda26
commit
ae6dd65e7a
@ -25,6 +25,7 @@ type Props = {
|
|||||||
}
|
}
|
||||||
export type PlayerInstance = {
|
export type PlayerInstance = {
|
||||||
play: (url: string, currentTime: number) => void;
|
play: (url: string, currentTime: number) => void;
|
||||||
|
pause: () => void;
|
||||||
getState: () => State;
|
getState: () => State;
|
||||||
}
|
}
|
||||||
export const Player = React.forwardRef<PlayerInstance, Props>((props, ref) => {
|
export const Player = React.forwardRef<PlayerInstance, Props>((props, ref) => {
|
||||||
@ -96,6 +97,10 @@ export const Player = React.forwardRef<PlayerInstance, Props>((props, ref) => {
|
|||||||
}, [])
|
}, [])
|
||||||
React.useImperativeHandle(ref, () => {
|
React.useImperativeHandle(ref, () => {
|
||||||
return {
|
return {
|
||||||
|
pause(){
|
||||||
|
if (!tcPlayer) return;
|
||||||
|
tcPlayer.pause()
|
||||||
|
},
|
||||||
play: (url, currentTime = 0) => {
|
play: (url, currentTime = 0) => {
|
||||||
console.log('play', url, currentTime)
|
console.log('play', url, currentTime)
|
||||||
if (!tcPlayer) return;
|
if (!tcPlayer) return;
|
||||||
|
@ -57,11 +57,7 @@ export const VideoListItem = (
|
|||||||
{... (sortable && !generating?listeners:{})}
|
{... (sortable && !generating?listeners:{})}
|
||||||
{... (sortable && !generating?attributes:{})}
|
{... (sortable && !generating?attributes:{})}
|
||||||
>{index}</div>
|
>{index}</div>
|
||||||
<div
|
<div className="col cover cursor-pointer">
|
||||||
className="col cover"
|
|
||||||
{... (sortable && !generating?listeners:{})}
|
|
||||||
{... (sortable && !generating?attributes:{})}
|
|
||||||
>
|
|
||||||
<div className="relative">
|
<div className="relative">
|
||||||
<img className="w-[100px] h-[56px] object-cover" src={video.cover || ImageCover}/>
|
<img className="w-[100px] h-[56px] object-cover" src={video.cover || ImageCover}/>
|
||||||
{generating &&
|
{generating &&
|
||||||
|
@ -20,6 +20,7 @@ const cache: { flvPlayer?: FlvJs.Player, timerPlayNext?: any, timerLoadState?: a
|
|||||||
export default function LiveIndex() {
|
export default function LiveIndex() {
|
||||||
|
|
||||||
const player = useRef<PlayerInstance | null>(null)
|
const player = useRef<PlayerInstance | null>(null)
|
||||||
|
|
||||||
const [videoData, setVideoData] = useState<LiveVideoInfo[]>([])
|
const [videoData, setVideoData] = useState<LiveVideoInfo[]>([])
|
||||||
const [modal, contextHolder] = Modal.useModal()
|
const [modal, contextHolder] = Modal.useModal()
|
||||||
const [checkedIdArray, setCheckedIdArray] = useState<number[]>([])
|
const [checkedIdArray, setCheckedIdArray] = useState<number[]>([])
|
||||||
@ -31,6 +32,7 @@ export default function LiveIndex() {
|
|||||||
muted: true,
|
muted: true,
|
||||||
showToTop: false,
|
showToTop: false,
|
||||||
checkedAll: false,
|
checkedAll: false,
|
||||||
|
originSort:''
|
||||||
})
|
})
|
||||||
const activeIndex = useRef(state.activeIndex)
|
const activeIndex = useRef(state.activeIndex)
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@ -111,6 +113,9 @@ export default function LiveIndex() {
|
|||||||
getList().then(res => {
|
getList().then(res => {
|
||||||
// console.log('origin list', res.list.map(s => s.id))
|
// console.log('origin list', res.list.map(s => s.id))
|
||||||
setVideoData(() => (res.list || []))
|
setVideoData(() => (res.list || []))
|
||||||
|
setState({
|
||||||
|
originSort: res.list?res.list.map(s => s.id).join(','):''
|
||||||
|
})
|
||||||
setCheckedIdArray([])
|
setCheckedIdArray([])
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -132,16 +137,22 @@ export default function LiveIndex() {
|
|||||||
setEditable(true)
|
setEditable(true)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
const newSort = videoData.map(s => s.id).join(',')
|
||||||
|
if(newSort == state.originSort){
|
||||||
|
setEditable(false)
|
||||||
|
return;
|
||||||
|
}
|
||||||
modal.confirm({
|
modal.confirm({
|
||||||
title: '提示',
|
title: '提示',
|
||||||
content: '是否采纳移动视频位置操作?',
|
content: '是否采纳移动视频位置操作?',
|
||||||
|
centered: true,
|
||||||
onOk: () => {
|
onOk: () => {
|
||||||
//showToast('编辑成功!!!', 'info');
|
//showToast('编辑成功!!!', 'info');
|
||||||
modifyOrder(videoData.map(s => s.id)).then(() => {
|
modifyOrder(videoData.map(s => s.id)).then(() => {
|
||||||
|
showToast('已完成直播队列的修改!','success')
|
||||||
setEditable(false)
|
setEditable(false)
|
||||||
loadList()
|
|
||||||
}).catch(() => {
|
}).catch(() => {
|
||||||
showToast('调整视频顺序失败,请重试!')
|
showToast('调整视频顺序失败,请重试!','warning')
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
onCancel: () => {
|
onCancel: () => {
|
||||||
|
@ -51,12 +51,19 @@ export default function VideoIndex() {
|
|||||||
|
|
||||||
// 播放视频
|
// 播放视频
|
||||||
const playVideo = (video: VideoInfo, playingIndex: number) => {
|
const playVideo = (video: VideoInfo, playingIndex: number) => {
|
||||||
console.log(video)
|
if(state.playingIndex == playingIndex){
|
||||||
if(video.status == VideoStatus.Generating ) return;
|
player.current?.pause();
|
||||||
if (video.oss_video_url && video.status !== 1) {
|
setState({playingIndex: -1})
|
||||||
setState({playingIndex})
|
return;
|
||||||
player.current?.play(video.oss_video_url, 0)
|
|
||||||
}
|
}
|
||||||
|
if(video.status == VideoStatus.Generating ) return;
|
||||||
|
setState({playingIndex})
|
||||||
|
player.current?.play('https://staticplus.gachafun.com/ai-collect/composite_video/2024-12-17/1186196465916190720.flv',30)
|
||||||
|
//
|
||||||
|
// if (video.oss_video_url && video.status !== 1) {
|
||||||
|
// setState({playingIndex})
|
||||||
|
// player.current?.play(video.oss_video_url, 0)
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
// 处理全选
|
// 处理全选
|
||||||
const handleAllCheckedChange = () => {
|
const handleAllCheckedChange = () => {
|
||||||
@ -66,10 +73,10 @@ export default function VideoIndex() {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
const handleModifySort = (items:VideoInfo[]) => {
|
const handleModifySort = (items:VideoInfo[]) => {
|
||||||
// .then(() => {
|
|
||||||
// showToast('调整视频顺序成功!','success')
|
modifyOrder(items.map(s => s.id)).then(() => {
|
||||||
// })
|
showToast('调整视频顺序成功!','success')
|
||||||
modifyOrder(items.map(s => s.id)).catch(()=>{
|
}).catch(()=>{
|
||||||
loadList();
|
loadList();
|
||||||
showToast('调整视频顺序失败,请重试!','warning')
|
showToast('调整视频顺序失败,请重试!','warning')
|
||||||
})
|
})
|
||||||
@ -105,7 +112,7 @@ export default function VideoIndex() {
|
|||||||
<Player
|
<Player
|
||||||
ref={player} url={videoData[state.playingIndex]?.oss_video_url}
|
ref={player} url={videoData[state.playingIndex]?.oss_video_url}
|
||||||
onChange={(state) => {
|
onChange={(state) => {
|
||||||
if (state.end || state.end) setState({playingIndex: -1})
|
if (state.end || state.error) setState({playingIndex: -1})
|
||||||
}}
|
}}
|
||||||
className="w-[360px] h-[640px] bg-white"/>
|
className="w-[360px] h-[640px] bg-white"/>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user