mirror of
https://gh-proxy.org/https://github.com/tiajinsha/JKVideo
synced 2026-07-08 07:28:37 +08:00
fix: quality switch not updating video playback
- Use qn-specific MPD filename (bili_dash_{qn}.mpd) so each quality
produces a distinct URI that triggers react-native-video to reload
- Add key={resolvedUrl} on <Video> to force remount on source change
This commit is contained in:
@@ -57,6 +57,7 @@ export function NativeVideoPlayer({
|
|||||||
<View style={[styles.container, style]}>
|
<View style={[styles.container, style]}>
|
||||||
{resolvedUrl ? (
|
{resolvedUrl ? (
|
||||||
<Video
|
<Video
|
||||||
|
key={resolvedUrl}
|
||||||
ref={videoRef}
|
ref={videoRef}
|
||||||
source={isDash
|
source={isDash
|
||||||
? { uri: resolvedUrl, type: 'mpd', headers: BILIBILI_HEADERS }
|
? { uri: resolvedUrl, type: 'mpd', headers: BILIBILI_HEADERS }
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import type { PlayUrlResponse } from '../services/types';
|
|||||||
*/
|
*/
|
||||||
export async function buildDashMpdUri(playData: PlayUrlResponse, qn: number): Promise<string> {
|
export async function buildDashMpdUri(playData: PlayUrlResponse, qn: number): Promise<string> {
|
||||||
const xml = buildMpdXml(playData, qn);
|
const xml = buildMpdXml(playData, qn);
|
||||||
const path = `${FileSystem.cacheDirectory}bili_dash.mpd`;
|
const path = `${FileSystem.cacheDirectory}bili_dash_${qn}.mpd`;
|
||||||
await FileSystem.writeAsStringAsync(path, xml, { encoding: FileSystem.EncodingType.UTF8 });
|
await FileSystem.writeAsStringAsync(path, xml, { encoding: FileSystem.EncodingType.UTF8 });
|
||||||
return path;
|
return path;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user