mirror of
https://github.com/zoriya/react-native-video.git
synced 2025-12-06 07:16:12 +00:00
Add optional mimeType string in source object
This commit is contained in:
@@ -234,19 +234,27 @@ class VideoPlayer extends VideoPlayerEvents implements VideoPlayerBase {
|
|||||||
| NoAutocomplete<VideoPlayerSource>
|
| NoAutocomplete<VideoPlayerSource>
|
||||||
| null,
|
| null,
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
const src =
|
if (!source) {
|
||||||
typeof source === "object" && source && "uri" in source
|
this.player.src([]);
|
||||||
? source.uri
|
this.player.reset();
|
||||||
: source;
|
return;
|
||||||
if (typeof src === "number") {
|
}
|
||||||
|
|
||||||
|
if (typeof source === "number") {
|
||||||
console.error(
|
console.error(
|
||||||
"A source uri must be a string. Numbers are only supported on native.",
|
"A source uri must be a string. Numbers are only supported on native.",
|
||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (typeof source === "string") {
|
||||||
|
source = { uri: source };
|
||||||
|
}
|
||||||
// TODO: handle start time
|
// TODO: handle start time
|
||||||
this.player.src(src);
|
this.player.src({
|
||||||
if (typeof source !== "object") return;
|
src: source.uri,
|
||||||
|
type: source.mimeType,
|
||||||
|
});
|
||||||
|
if (source.initializeOnCreation) await this.preload();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Text Track Management
|
// Text Track Management
|
||||||
|
|||||||
@@ -14,6 +14,11 @@ export type VideoConfig = {
|
|||||||
* ```
|
* ```
|
||||||
*/
|
*/
|
||||||
uri: VideoSource;
|
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.
|
* The headers to be sent with the request.
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user