mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-09-08 10:46:06 +00:00
refactor(studio): reuse player probe errors
This commit is contained in:
@@ -7,6 +7,15 @@ import {
|
||||
shouldShowCompositionLoadingOverlay,
|
||||
} from "./Player";
|
||||
|
||||
function createAudioIframe() {
|
||||
const iframe = document.createElement("iframe");
|
||||
document.body.appendChild(iframe);
|
||||
const audio = iframe.contentDocument?.createElement("audio");
|
||||
expect(audio).toBeDefined();
|
||||
iframe.contentDocument?.body.appendChild(audio!);
|
||||
return { audio: audio!, iframe };
|
||||
}
|
||||
|
||||
describe("preview errors", () => {
|
||||
it("reads the player probe error for the visible retry state", () => {
|
||||
expect(
|
||||
@@ -35,10 +44,7 @@ describe("composition loading overlay", () => {
|
||||
});
|
||||
|
||||
it("keeps the asset overlay up while media is still buffering", () => {
|
||||
const iframe = document.createElement("iframe");
|
||||
document.body.appendChild(iframe);
|
||||
const audio = iframe.contentDocument?.createElement("audio");
|
||||
expect(audio).toBeDefined();
|
||||
const { audio, iframe } = createAudioIframe();
|
||||
Object.defineProperty(audio, "readyState", {
|
||||
value: 0,
|
||||
configurable: true,
|
||||
@@ -47,7 +53,6 @@ describe("composition loading overlay", () => {
|
||||
value: 2,
|
||||
configurable: true,
|
||||
});
|
||||
iframe.contentDocument?.body.appendChild(audio!);
|
||||
|
||||
expect(hasUnloadedAssets(iframe, false)).toBe(true);
|
||||
|
||||
@@ -55,10 +60,7 @@ describe("composition loading overlay", () => {
|
||||
});
|
||||
|
||||
it("does not keep the asset overlay stuck on failed media sources", () => {
|
||||
const iframe = document.createElement("iframe");
|
||||
document.body.appendChild(iframe);
|
||||
const audio = iframe.contentDocument?.createElement("audio");
|
||||
expect(audio).toBeDefined();
|
||||
const { audio, iframe } = createAudioIframe();
|
||||
Object.defineProperty(audio, "error", {
|
||||
value: { code: 4, message: "format error" },
|
||||
configurable: true,
|
||||
@@ -71,7 +73,6 @@ describe("composition loading overlay", () => {
|
||||
value: 3,
|
||||
configurable: true,
|
||||
});
|
||||
iframe.contentDocument?.body.appendChild(audio!);
|
||||
|
||||
expect(hasUnloadedAssets(iframe, false)).toBe(false);
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ import { HyperframesLoader } from "../../components/ui";
|
||||
interface PlayerProps {
|
||||
projectId?: string;
|
||||
directUrl?: string;
|
||||
onLoad: (reportError: (message: string) => void) => void;
|
||||
onLoad: () => void;
|
||||
onCompositionLoadingChange?: (loading: boolean) => void;
|
||||
portrait?: boolean;
|
||||
style?: React.CSSProperties;
|
||||
@@ -208,10 +208,7 @@ export const Player = forwardRef<HTMLIFrameElement, PlayerProps>(
|
||||
const onEnd = () => container.classList.remove("preview-revealing");
|
||||
container.addEventListener("animationend", onEnd, { once: true });
|
||||
}
|
||||
onLoad((message) => {
|
||||
setPreviewError(message);
|
||||
setCompositionLoading(false);
|
||||
});
|
||||
onLoad();
|
||||
|
||||
// Show a loading overlay until every `<video>`/`<audio>` and Lottie
|
||||
// asset is ready. Without this users can click play before audio has
|
||||
|
||||
Reference in New Issue
Block a user