feat: support start time

This commit is contained in:
Fredrik Burmester
2024-10-16 08:21:42 +02:00
parent 951a9d08ba
commit fcffee1981
3 changed files with 10 additions and 0 deletions

View File

@@ -97,6 +97,7 @@ class VlcPlayerView: ExpoView {
let initType = source["initType"] as? Int ?? 0
let autoplay = source["autoplay"] as? Bool ?? false
let isNetwork = source["isNetwork"] as? Bool ?? false
let startPosition = source["startPosition"] as? Int32 ?? 0
guard let uri = uri, !uri.isEmpty else { return }
@@ -152,6 +153,10 @@ class VlcPlayerView: ExpoView {
self.mediaPlayer?.media = media
if startPosition > 0 {
self.mediaPlayer?.time = VLCTime(int: startPosition)
}
if autoplay {
self.play()
}

View File

@@ -43,6 +43,7 @@ export type VlcPlayerSource = {
autoplay?: boolean;
initOptions?: any[];
mediaOptions?: { [key: string]: any };
startPosition?: number;
};
export type TrackInfo = {

View File

@@ -101,6 +101,10 @@ const VlcPlayerView = React.forwardRef<VlcPlayerViewRef, VlcPlayerViewProps>(
const processedSource: VlcPlayerSource =
typeof source === "string" ? { uri: source } : source;
if (processedSource.startPosition !== undefined) {
processedSource.startPosition = Math.floor(processedSource.startPosition);
}
return (
<NativeView
{...otherProps}