Add optional mimeType string in source object

This commit is contained in:
2025-10-14 12:09:16 +02:00
parent a964c83ecc
commit 70405e7052
2 changed files with 20 additions and 7 deletions

View File

@@ -234,19 +234,27 @@ class VideoPlayer extends VideoPlayerEvents implements VideoPlayerBase {
| NoAutocomplete<VideoPlayerSource>
| null,
): Promise<void> {
const src =
typeof source === "object" && source && "uri" in source
? source.uri
: source;
if (typeof src === "number") {
if (!source) {
this.player.src([]);
this.player.reset();
return;
}
if (typeof source === "number") {
console.error(
"A source uri must be a string. Numbers are only supported on native.",
);
return;
}
if (typeof source === "string") {
source = { uri: source };
}
// TODO: handle start time
this.player.src(src);
if (typeof source !== "object") return;
this.player.src({
src: source.uri,
type: source.mimeType,
});
if (source.initializeOnCreation) await this.preload();
}
// Text Track Management

View File

@@ -14,6 +14,11 @@ export type VideoConfig = {
* ```
*/
uri: VideoSource;
/**
* complete mime type, used to select a background for playback.
* if not specified, the extension of the url might be used
*/
mimeType?: string
/**
* The headers to be sent with the request.
*/