mirror of
https://gh-proxy.org/https://github.com/tiajinsha/JKVideo
synced 2026-07-08 07:28:37 +08:00
1
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { useState, useEffect } from 'react';
|
||||
import { useState, useEffect, useCallback } from 'react';
|
||||
import { getLiveRoomDetail, getLiveAnchorInfo, getLiveStreamUrl } from '../services/bilibili';
|
||||
import type { LiveRoomDetail, LiveAnchorInfo, LiveStreamInfo } from '../services/types';
|
||||
|
||||
@@ -33,7 +33,7 @@ export function useLiveDetail(roomId: number) {
|
||||
]);
|
||||
if (cancelled) return;
|
||||
|
||||
let stream: LiveStreamInfo = { hlsUrl: '', flvUrl: '', qn: 0 };
|
||||
let stream: LiveStreamInfo = { hlsUrl: '', flvUrl: '', qn: 0, qualities: [] };
|
||||
if (room.live_status === 1) {
|
||||
stream = await getLiveStreamUrl(roomId);
|
||||
}
|
||||
@@ -50,5 +50,12 @@ export function useLiveDetail(roomId: number) {
|
||||
return () => { cancelled = true; };
|
||||
}, [roomId]);
|
||||
|
||||
return state;
|
||||
const changeQuality = useCallback(async (qn: number) => {
|
||||
try {
|
||||
const stream = await getLiveStreamUrl(roomId, qn);
|
||||
setState(prev => ({ ...prev, stream }));
|
||||
} catch { /* ignore */ }
|
||||
}, [roomId]);
|
||||
|
||||
return { ...state, changeQuality };
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user