diff --git a/client/viewer.tsx b/client/viewer.tsx index 2c48d1b..f74c250 100644 --- a/client/viewer.tsx +++ b/client/viewer.tsx @@ -39,8 +39,10 @@ const resolveVideoURL = async (did: string, blob: string): Promise => { method: "POST", headers: { "content-encoding": "application/json" }, body: JSON.stringify({ repo: did, blob }), - }).then((r) => r.json()); - return `/user-content/${res.filename}`; + }); + if (res.status !== 200) throw new Error("got error fetching video cdn url"); + const data = await res.json(); + return `/user-content/${data.filename}`; }; const main = async () => { @@ -55,21 +57,23 @@ const main = async () => { const did = repo.startsWith("did:") ? repo : await resolveHandle(repo); - const video = await fetchVideoRecord(did, rkey); - const videoURL = await resolveVideoURL(did, video.video.ref.$link); - - player.append( + const record = await fetchVideoRecord(did, rkey); + const videoURL = await resolveVideoURL(did, record.video.ref.$link); + const video = ( - ); + ) as HTMLVideoElement; + video.volume = 0.8; - if (video.title) { - player.append(

{video.title}

); - document.title = `${video.title} | video.cerulea.blue`; + player.append(video); + + if (record.title) { + player.append(

{record.title}

); + document.title = `${record.title} | video.cerulea.blue`; } - if (video.description) - player.append(

{video.description}

); + if (record.description) + player.append(

{record.description}

); }; main();