Skip to content

Commit

Permalink
Merge pull request #50 from cloudflare/add-start-time
Browse files Browse the repository at this point in the history
Add start time
  • Loading branch information
third774 authored Dec 17, 2021
2 parents 21ffff3 + 6bb3a63 commit 2130555
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 0 deletions.
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,19 @@ export type StreamProps = {
* The <video> element does not force the browser to follow the value of this attribute; it is a mere hint. Even though the preload="none" option is a valid HTML5 attribute, Stream player will always load some metadata to initialize the player. The amount of data loaded in this case is negligable.
*/
preload?: "auto" | "metadata" | "none" | boolean;
/**
* Any valid CSS color value provided will be applied to certain elements of the player's UI.
* https://developer.mozilla.org/en-US/docs/Web/CSS/color_value
*/
primaryColor?: string;
/**
* A timestamp that specifies the time when playback begins.
* If a plain number is used such as ?startTime=123, it will
* be interpreted as 123 seconds. More human readable timestamps
* can also be used, such as ?startTime=1h12m27s for 1 hour,
* 12 minutes, and 27 seconds.
*/
startTime?: string | number;
/**
* Automatically manages the aspect ratio of the iframe for you. Defaults to true. If you want to manually handle the styles yourself, set this to false.
*/
Expand Down
2 changes: 2 additions & 0 deletions src/Stream.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ export const StreamEmbed: FC<StreamProps> = ({
poster,
currentTime = 0,
volume = 1,
startTime,
streamRef,
responsive = true,
className,
Expand Down Expand Up @@ -154,6 +155,7 @@ export const StreamEmbed: FC<StreamProps> = ({
primaryColor,
adUrl,
defaultTextTrack,
startTime,
});

// While it's easier for most consumers to simply provide the video id
Expand Down
8 changes: 8 additions & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,14 @@ export interface StreamProps {
* Either the video id or the signed url for the video you’ve uploaded to Cloudflare Stream should be included here.
*/
src: string;
/**
* A timestamp that specifies the time when playback begins.
* If a plain number is used such as ?startTime=123, it will
* be interpreted as 123 seconds. More human readable timestamps
* can also be used, such as ?startTime=1h12m27s for 1 hour,
* 12 minutes, and 27 seconds.
*/
startTime?: string | number;
/**
* Ref for accessing the underlying stream element. Useful for providing imperative access to the player API:
* https://developers.cloudflare.com/stream/viewing-videos/using-the-player-api
Expand Down
3 changes: 3 additions & 0 deletions src/useIframeSrc.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ interface IframeSrcOptions {
controls?: boolean;
poster?: string;
primaryColor?: string;
startTime?: string | number;
adUrl?: string;
defaultTextTrack?: string;
preload?: Preload;
Expand All @@ -24,6 +25,7 @@ export function useIframeSrc(
poster,
primaryColor,
adUrl,
startTime,
defaultTextTrack,
}: IframeSrcOptions
) {
Expand All @@ -33,6 +35,7 @@ export function useIframeSrc(
defaultTextTrack &&
`defaultTextTrack=${encodeURIComponent(defaultTextTrack)}`,
primaryColor && `primaryColor=${encodeURIComponent(primaryColor)}`,
startTime && `startTime=${startTime}`,
muted && "muted=true",
preload && `preload=${preload}`,
loop && "loop=true",
Expand Down

0 comments on commit 2130555

Please sign in to comment.