@@ -201,22 +155,22 @@ export default function LiveIndex() {
const {active, over} = e;
if (over && active.id !== over.id) {
let oldIndex = -1, newIndex = -1;
- const originArr = [...videoData]
+ // const originArr = [...videoData]
setVideoData((items) => {
oldIndex = items.findIndex(s => s.id == active.id);
newIndex = items.findIndex(s => s.id == over.id);
return arrayMove(items, oldIndex, newIndex);
});
- modal.confirm({
- title: '提示',
- content: '是否要移动到指定位置',
- onCancel: () => {
- setVideoData(originArr);
- },
- onOk: () => {
- setVideoData([...videoData])
- }
- })
+ // modal.confirm({
+ // title: '提示',
+ // content: '是否要移动到指定位置',
+ // onCancel: () => {
+ // setVideoData(originArr);
+ // },
+ // onOk: () => {
+ // setVideoData([...videoData])
+ // }
+ // })
}
}}>
@@ -225,16 +179,18 @@ export default function LiveIndex() {
video={v}
index={index + 1}
id={v.id}
- active={state.activeIndex == index}
key={index}
+ active={state.activeIndex == index}
className={`list-item-${index} mt-3 mb-2`}
+ checked={checkedIdArray.includes(v.id)}
onCheckedChange={(checked) => {
setCheckedIdArray(idArray => {
return checked ? idArray.concat(v.id) : idArray.filter(id => id != v.id);
})
}}
onRemove={() => processDeleteVideo([v.id])}
- editable={editable}
+ editable={!editable}
+ sortable={editable}
/>))}
diff --git a/src/pages/test.tsx b/src/pages/test.tsx
new file mode 100644
index 0000000..80d3c0a
--- /dev/null
+++ b/src/pages/test.tsx
@@ -0,0 +1,90 @@
+import {useRef, useState} from "react";
+import {Button} from "antd";
+import FlvJs from "flv.js";
+
+const list = [
+ {
+ "id": 10,
+ "cover_url": "",
+ "video_id": 51,
+ "video_title": "以军称在加沙地带打死一名哈马斯高级官员",
+ "video_duration": 31910,
+ "video_oss_url": "https://staticplus.gachafun.com/ai-collect/composite_video/2024-12-14/1185251497659736064.flv",
+ "status": 4,
+ "order_no": ""
+ },
+ {
+ "id": 8,
+ "cover_url": "",
+ "video_id": 43,
+ "video_title": "历时12天史上第三人 尹锡悦总统弹劾案获通过 一文梳理韩国政坛众生相",
+ "video_duration": 728840,
+ "video_oss_url": "https://staticplus.gachafun.com/ai-collect/composite_video/2024-12-14/1185229869001351168.flv",
+ "status": 4,
+ "order_no": ""
+ },
+ {
+ "id": 9,
+ "cover_url": "",
+ "video_id": 44,
+ "video_title": "推动房地产市场止跌回稳,发力重点在哪里?",
+ "video_duration": 57500,
+ "video_oss_url": "https://staticplus.gachafun.com/ai-collect/composite_video/2024-12-14/1185229857764810752.flv",
+ "status": 4,
+ "order_no": ""
+ },
+ {
+ "id": 11,
+ "cover_url": "",
+ "video_id": 52,
+ "video_title": "以军称在加沙地带打死一名哈马斯高级官员",
+ "video_duration": 37980,
+ "video_oss_url": "https://staticplus.gachafun.com/ai-collect/composite_video/2024-12-14/1185251495390617600.flv",
+ "status": 4,
+ "order_no": ""
+ }
+]
+
+const cache:{
+ flvPlayer?: FlvJs.Player
+} = {
+
+}
+export default function Test() {
+ const videoRef = useRef
(null)
+ const [index, setIndex] = useState(-1)
+ const load = (url: string) => {
+ if (FlvJs.isSupported()) {
+ if(cache.flvPlayer){
+ cache.flvPlayer.pause()
+ cache.flvPlayer.unload()
+ }
+ cache.flvPlayer = FlvJs.createPlayer({
+ type: 'flv',
+ url: url
+ })
+
+ cache.flvPlayer.attachMediaElement(videoRef.current!)
+ cache.flvPlayer.load()
+ cache.flvPlayer.play()
+ }
+ // const url = 'https://staticplus.gachafun.com/ai-collect/composite_video/2024-12-14/1185229869001351168.flv'
+ // if (videoRef.current) {
+ // videoRef.current!.src = url
+ // videoRef.current?.play()
+ // }
+ }
+ const play = () => {
+ const next = index >= list.length - 1 ? 0 : index + 1
+ load(list[next].video_oss_url)
+ setIndex(next)
+ }
+ return (
+
+
+
+
+
)
+}
\ No newline at end of file
diff --git a/src/pages/video/index.tsx b/src/pages/video/index.tsx
index c8adcad..cdbbda4 100644
--- a/src/pages/video/index.tsx
+++ b/src/pages/video/index.tsx
@@ -10,11 +10,11 @@ import {VideoListItem} from "@/components/video/video-list-item.tsx";
import ArticleEditModal from "@/components/article/edit-modal.tsx";
import {deleteByIds, getList, modifyOrder, push2room} from "@/service/api/video.ts";
import {formatDuration} from "@/util/strings.ts";
-import ButtonPush2Room from "@/pages/video/components/button-push2room.tsx";
import ButtonBatch from "@/components/button-batch.tsx";
-import {showErrorToast, showToast} from "@/components/message.ts";
-
+import {showToast} from "@/components/message.ts";
+import FlvJs from "flv.js";
+const cache:{flvPlayer?: FlvJs.Player} = {}
export default function VideoIndex() {
const [editId, setEditId] = useState(-1)
const [videoData, setVideoData] = useState([])
@@ -29,7 +29,6 @@ export default function VideoIndex() {
// 加载列表
const loadList = () => {
getList().then((ret) => {
- console.log('origin list', ret.list.map(s => s.id))
setCheckedIdArray([])
setVideoData(ret.list || [])
setState({checkedAll: false, playingIndex: -1})
@@ -40,6 +39,21 @@ export default function VideoIndex() {
const playVideo = (video: VideoInfo, playingIndex: number) => {
if (videoRef.current && video.oss_video_url) {
setState({playingIndex})
+ if (FlvJs.isSupported()) {
+ // 已经有播放实例 则销毁
+ if(cache.flvPlayer){
+ cache.flvPlayer.pause()
+ cache.flvPlayer.unload()
+ }
+ cache.flvPlayer = FlvJs.createPlayer({
+ type: 'flv',
+ url: video.oss_video_url
+ })
+
+ cache.flvPlayer.attachMediaElement(videoRef.current!)
+ cache.flvPlayer.load()
+ cache.flvPlayer.play()
+ }
videoRef.current!.src = video.oss_video_url
}
}
@@ -51,7 +65,6 @@ export default function VideoIndex() {
})
}
const handleModifySort = () => {
-
setVideoData((items) => {
modifyOrder(items.map(s => s.id)).catch(() => {
showToast('调整视频顺序失败,请重试!')
@@ -81,7 +94,10 @@ export default function VideoIndex() {
selected={checkedIdArray}
emptyMessage={`请选择要删除的新闻视频`}
confirmMessage={`是否删除当前的${checkedIdArray.length}个新闻视频?`}
- onSuccess={loadList}
+ onSuccess={()=>{
+ showToast('删除成功!','success')
+ loadList()
+ }}
>批量删除