Skip to content

Commit

Permalink
fix(player): maintain provided source order
Browse files Browse the repository at this point in the history
  • Loading branch information
mihar-22 committed Jun 19, 2024
1 parent f968659 commit f583604
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions packages/vidstack/src/components/provider/source-select.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ export class SourceSelection {

this._loader.set(loader);
this._initialize = true;
break;
}
}

Expand Down Expand Up @@ -327,15 +328,13 @@ export class SourceSelection {
}

function normalizeSrc(src: MediaPlayerProps['src']): Src[] {
return (isArray(src) ? src : [src])
.map((src) => {
if (isString(src)) {
return { src, type: inferType(src) };
} else {
return { ...src, type: inferType(src.src, src.type) };
}
})
.sort((a) => (a.type === '?' ? 1 : -1));
return (isArray(src) ? src : [src]).map((src) => {
if (isString(src)) {
return { src, type: inferType(src) };
} else {
return { ...src, type: inferType(src.src, src.type) };
}
});
}

function inferType(src: unknown, type?: string) {
Expand Down

0 comments on commit f583604

Please sign in to comment.