Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions src/components/canvas/players/image-player.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,14 +91,13 @@ export class ImagePlayer extends Player {
throw new Error("Image asset has no src to load.");
}

const corsUrl = `${src}${src.includes("?") ? "&" : "?"}x-cors=1`;
const loadOptions: pixi.UnresolvedAsset = { src: corsUrl, crossorigin: "anonymous", data: {} };
const texture = await this.edit.assetLoader.load<pixi.Texture<pixi.ImageSource>>(corsUrl, loadOptions);
const loadOptions: pixi.UnresolvedAsset = { src, crossorigin: "anonymous", data: {} };
const texture = await this.edit.assetLoader.load<pixi.Texture<pixi.ImageSource>>(src, loadOptions);

if (!(texture?.source instanceof pixi.ImageSource)) {
if (texture) {
texture.destroy(true);
await this.edit.assetLoader.rejectAsset(corsUrl);
await this.edit.assetLoader.rejectAsset(src);
}
throw new Error(`Invalid image source '${src}'.`);
}
Expand Down
7 changes: 3 additions & 4 deletions src/components/canvas/players/image-to-video-player.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,14 +114,13 @@ export class ImageToVideoPlayer extends Player {

private async tryLoadTexture(src: string): Promise<boolean> {
try {
const corsUrl = `${src}${src.includes("?") ? "&" : "?"}x-cors=1`;
const loadOptions: pixi.UnresolvedAsset = { src: corsUrl, crossorigin: "anonymous", data: {} };
const texture = await this.edit.assetLoader.load<pixi.Texture<pixi.ImageSource>>(corsUrl, loadOptions);
const loadOptions: pixi.UnresolvedAsset = { src, crossorigin: "anonymous", data: {} };
const texture = await this.edit.assetLoader.load<pixi.Texture<pixi.ImageSource>>(src, loadOptions);

if (!(texture?.source instanceof pixi.ImageSource)) {
if (texture) {
texture.destroy(true);
await this.edit.assetLoader.rejectAsset(corsUrl);
await this.edit.assetLoader.rejectAsset(src);
}
return false;
}
Expand Down
5 changes: 2 additions & 3 deletions src/components/canvas/players/video-player.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,12 +178,11 @@ export class VideoPlayer extends Player {
throw new Error(`Video source '${src}' is not supported. .mov files cannot be played in the browser. Please convert to .webm or .mp4 first.`);
}

const corsUrl = `${src}${src.includes("?") ? "&" : "?"}x-cors=1`;
const loadOptions: pixi.UnresolvedAsset = { src: corsUrl, data: { autoPlay: false, muted: false } };
const loadOptions: pixi.UnresolvedAsset = { src, data: { autoPlay: false, muted: false } };

// Use unique loader to create independent video element per player
// This prevents conflicts when multiple clips use the same video source
const texture = await this.edit.assetLoader.loadVideoUnique(corsUrl, loadOptions);
const texture = await this.edit.assetLoader.loadVideoUnique(src, loadOptions);

if (!texture || !(texture.source instanceof pixi.VideoSource)) {
throw new Error(`Invalid video source '${src}'.`);
Expand Down