|
@@ -1,5 +1,6 @@
|
|
|
import { getRandomString } from 'billd-utils';
|
|
import { getRandomString } from 'billd-utils';
|
|
|
import { onUnmounted, ref, watch } from 'vue';
|
|
import { onUnmounted, ref, watch } from 'vue';
|
|
|
|
|
+import { useRoute } from 'vue-router';
|
|
|
|
|
|
|
|
import { commentAuthTip, loginTip } from '@/hooks/use-login';
|
|
import { commentAuthTip, loginTip } from '@/hooks/use-login';
|
|
|
import { useFlvPlay, useHlsPlay } from '@/hooks/use-play';
|
|
import { useFlvPlay, useHlsPlay } from '@/hooks/use-play';
|
|
@@ -12,13 +13,12 @@ import {
|
|
|
import { useAppStore } from '@/store/app';
|
|
import { useAppStore } from '@/store/app';
|
|
|
import { usePiniaCacheStore } from '@/store/cache';
|
|
import { usePiniaCacheStore } from '@/store/cache';
|
|
|
import { useNetworkStore } from '@/store/network';
|
|
import { useNetworkStore } from '@/store/network';
|
|
|
-import { useUserStore } from '@/store/user';
|
|
|
|
|
import { ILiveRoom, LiveRoomTypeEnum } from '@/types/ILiveRoom';
|
|
import { ILiveRoom, LiveRoomTypeEnum } from '@/types/ILiveRoom';
|
|
|
import { WsMessageType, WsMsgTypeEnum } from '@/types/websocket';
|
|
import { WsMessageType, WsMsgTypeEnum } from '@/types/websocket';
|
|
|
import { createVideo, videoToCanvas } from '@/utils';
|
|
import { createVideo, videoToCanvas } from '@/utils';
|
|
|
|
|
|
|
|
export function usePull(roomId: string) {
|
|
export function usePull(roomId: string) {
|
|
|
- const userStore = useUserStore();
|
|
|
|
|
|
|
+ const route = useRoute();
|
|
|
const networkStore = useNetworkStore();
|
|
const networkStore = useNetworkStore();
|
|
|
const cacheStore = usePiniaCacheStore();
|
|
const cacheStore = usePiniaCacheStore();
|
|
|
const appStore = useAppStore();
|
|
const appStore = useAppStore();
|
|
@@ -33,15 +33,9 @@ export function usePull(roomId: string) {
|
|
|
const hlsurl = ref('');
|
|
const hlsurl = ref('');
|
|
|
const videoWrapRef = ref<HTMLDivElement>();
|
|
const videoWrapRef = ref<HTMLDivElement>();
|
|
|
const videoHeight = ref();
|
|
const videoHeight = ref();
|
|
|
- const sidebarList = ref<
|
|
|
|
|
- {
|
|
|
|
|
- socketId: string;
|
|
|
|
|
- }[]
|
|
|
|
|
- >([]);
|
|
|
|
|
const videoElArr = ref<HTMLVideoElement[]>([]);
|
|
const videoElArr = ref<HTMLVideoElement[]>([]);
|
|
|
const remoteVideo = ref<HTMLElement[]>([]);
|
|
const remoteVideo = ref<HTMLElement[]>([]);
|
|
|
const {
|
|
const {
|
|
|
- isPull,
|
|
|
|
|
mySocketId,
|
|
mySocketId,
|
|
|
initWs,
|
|
initWs,
|
|
|
roomLiving,
|
|
roomLiving,
|
|
@@ -50,7 +44,6 @@ export function usePull(roomId: string) {
|
|
|
damuList,
|
|
damuList,
|
|
|
handleSendGetLiveUser,
|
|
handleSendGetLiveUser,
|
|
|
} = useWebsocket();
|
|
} = useWebsocket();
|
|
|
- isPull.value = true;
|
|
|
|
|
const { flvVideoEl, flvIsPlaying, startFlvPlay, destroyFlv } = useFlvPlay();
|
|
const { flvVideoEl, flvIsPlaying, startFlvPlay, destroyFlv } = useFlvPlay();
|
|
|
const { hlsVideoEl, hlsIsPlaying, startHlsPlay, destroyHls } = useHlsPlay();
|
|
const { hlsVideoEl, hlsIsPlaying, startHlsPlay, destroyHls } = useHlsPlay();
|
|
|
const stopDrawingArr = ref<any[]>([]);
|
|
const stopDrawingArr = ref<any[]>([]);
|
|
@@ -68,17 +61,6 @@ export function usePull(roomId: string) {
|
|
|
remoteVideo.value = [];
|
|
remoteVideo.value = [];
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- watch(
|
|
|
|
|
- () => appStore.pkStream,
|
|
|
|
|
- (newval) => {
|
|
|
|
|
- console.log('pkStream变了', newval);
|
|
|
|
|
- stopDrawingArr.value = [];
|
|
|
|
|
- stopDrawingArr.value.forEach((cb) => cb());
|
|
|
|
|
- if (videoWrapRef.value) {
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- );
|
|
|
|
|
-
|
|
|
|
|
watch(hlsVideoEl, () => {
|
|
watch(hlsVideoEl, () => {
|
|
|
stopDrawingArr.value = [];
|
|
stopDrawingArr.value = [];
|
|
|
stopDrawingArr.value.forEach((cb) => cb());
|
|
stopDrawingArr.value.forEach((cb) => cb());
|
|
@@ -125,7 +107,6 @@ export function usePull(roomId: string) {
|
|
|
videoHeight.value = `${w}x${h}`;
|
|
videoHeight.value = `${w}x${h}`;
|
|
|
},
|
|
},
|
|
|
});
|
|
});
|
|
|
- console.log(canvas, 2221211223);
|
|
|
|
|
stopDrawingArr.value.push(stopDrawing);
|
|
stopDrawingArr.value.push(stopDrawing);
|
|
|
remoteVideo.value.push(canvas);
|
|
remoteVideo.value.push(canvas);
|
|
|
videoLoading.value = false;
|
|
videoLoading.value = false;
|
|
@@ -198,12 +179,15 @@ export function usePull(roomId: string) {
|
|
|
LiveRoomTypeEnum.msr,
|
|
LiveRoomTypeEnum.msr,
|
|
|
LiveRoomTypeEnum.srs,
|
|
LiveRoomTypeEnum.srs,
|
|
|
LiveRoomTypeEnum.obs,
|
|
LiveRoomTypeEnum.obs,
|
|
|
- LiveRoomTypeEnum.pk,
|
|
|
|
|
LiveRoomTypeEnum.tencent_css,
|
|
LiveRoomTypeEnum.tencent_css,
|
|
|
LiveRoomTypeEnum.tencent_css_pk,
|
|
LiveRoomTypeEnum.tencent_css_pk,
|
|
|
].includes(liveRoomInfo.type!)
|
|
].includes(liveRoomInfo.type!)
|
|
|
) {
|
|
) {
|
|
|
handlePlay(liveRoomInfo!);
|
|
handlePlay(liveRoomInfo!);
|
|
|
|
|
+ } else if (LiveRoomTypeEnum.pk === liveRoomInfo.type!) {
|
|
|
|
|
+ if (!route.query.pkKey) {
|
|
|
|
|
+ handlePlay(liveRoomInfo!);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
} else {
|
|
} else {
|
|
|
closeRtc();
|
|
closeRtc();
|
|
@@ -283,6 +267,7 @@ export function usePull(roomId: string) {
|
|
|
isPlaying.value = newVal;
|
|
isPlaying.value = newVal;
|
|
|
}
|
|
}
|
|
|
);
|
|
);
|
|
|
|
|
+
|
|
|
watch(
|
|
watch(
|
|
|
() => flvIsPlaying.value,
|
|
() => flvIsPlaying.value,
|
|
|
(newVal) => {
|
|
(newVal) => {
|
|
@@ -290,21 +275,6 @@ export function usePull(roomId: string) {
|
|
|
}
|
|
}
|
|
|
);
|
|
);
|
|
|
|
|
|
|
|
- watch(
|
|
|
|
|
- () => networkStore.rtcMap,
|
|
|
|
|
- (newVal) => {
|
|
|
|
|
- if (appStore.liveRoomInfo?.type === LiveRoomTypeEnum.wertc_live) {
|
|
|
|
|
- newVal.forEach((item) => {
|
|
|
|
|
- videoLoading.value = false;
|
|
|
|
|
- });
|
|
|
|
|
- }
|
|
|
|
|
- },
|
|
|
|
|
- {
|
|
|
|
|
- deep: true,
|
|
|
|
|
- immediate: true,
|
|
|
|
|
- }
|
|
|
|
|
- );
|
|
|
|
|
-
|
|
|
|
|
watch(
|
|
watch(
|
|
|
() => localStream.value,
|
|
() => localStream.value,
|
|
|
(val) => {
|
|
(val) => {
|
|
@@ -364,19 +334,6 @@ export function usePull(roomId: string) {
|
|
|
{ deep: true }
|
|
{ deep: true }
|
|
|
);
|
|
);
|
|
|
|
|
|
|
|
- watch(
|
|
|
|
|
- [
|
|
|
|
|
- () => userStore.userInfo,
|
|
|
|
|
- () => networkStore.wsMap.get(roomId)?.socketIo?.connected,
|
|
|
|
|
- ],
|
|
|
|
|
- ([userInfo, connected]) => {
|
|
|
|
|
- if (userInfo && connected) {
|
|
|
|
|
- const instance = networkStore.wsMap.get(roomId);
|
|
|
|
|
- if (!instance) return;
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- );
|
|
|
|
|
-
|
|
|
|
|
function initPull(autolay = true) {
|
|
function initPull(autolay = true) {
|
|
|
autoplayVal.value = autolay;
|
|
autoplayVal.value = autolay;
|
|
|
if (autoplayVal.value) {
|
|
if (autoplayVal.value) {
|
|
@@ -400,10 +357,6 @@ export function usePull(roomId: string) {
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- function addVideo() {
|
|
|
|
|
- sidebarList.value.push({ socketId: mySocketId.value });
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
function keydownDanmu(event: KeyboardEvent) {
|
|
function keydownDanmu(event: KeyboardEvent) {
|
|
|
const key = event.key.toLowerCase();
|
|
const key = event.key.toLowerCase();
|
|
|
if (key === 'enter') {
|
|
if (key === 'enter') {
|
|
@@ -453,7 +406,6 @@ export function usePull(roomId: string) {
|
|
|
closeRtc,
|
|
closeRtc,
|
|
|
keydownDanmu,
|
|
keydownDanmu,
|
|
|
sendDanmu,
|
|
sendDanmu,
|
|
|
- addVideo,
|
|
|
|
|
handleSendGetLiveUser,
|
|
handleSendGetLiveUser,
|
|
|
danmuMsgType,
|
|
danmuMsgType,
|
|
|
isPlaying,
|
|
isPlaying,
|
|
@@ -466,7 +418,6 @@ export function usePull(roomId: string) {
|
|
|
videoLoading,
|
|
videoLoading,
|
|
|
damuList,
|
|
damuList,
|
|
|
liveUserList,
|
|
liveUserList,
|
|
|
- sidebarList,
|
|
|
|
|
danmuStr,
|
|
danmuStr,
|
|
|
anchorInfo,
|
|
anchorInfo,
|
|
|
};
|
|
};
|