gx
chenyc
2025-06-12 7b72ac13a83764a662159d4a49b7fffb90476ecb
1
2
3
4
5
6
7
8
9
10
11
12
import { bufferToVideo } from './bufferToVideo';
import { fetchOrThrow } from './fetchOrThrow';
 
export async function fetchVideo(uri: string): Promise<HTMLVideoElement> {
  const res = await fetchOrThrow(uri);
  const blob = await (res).blob();
 
  if (!blob.type.startsWith('video/')) {
    throw new Error(`fetchVideo - expected blob type to be of type video/*, instead have: ${blob.type}, for url: ${res.url}`);
  }
  return bufferToVideo(blob);
}