-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #52 from sean1832/dev
Implement new features and settings for YouTube videos and add math helper for time conversion
- Loading branch information
Showing
9 changed files
with
163 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,28 @@ | ||
import React from "react"; | ||
import { cn } from "@/utils/cn"; | ||
import { SetYoutubeUrl } from "@/lib/youtubeUtil"; | ||
import propTypes from "prop-types"; | ||
|
||
const YoutubeVideo = ({ src, alt, mute, className }) => { | ||
const YoutubeVideo = ({ src, alt, className, startTime, isAutoplay, isLoop, isMutted }) => { | ||
return ( | ||
<iframe | ||
src={src + (mute ? "&mute=1" : "")} | ||
src={SetYoutubeUrl(src, startTime, isAutoplay, isMutted, isLoop)} | ||
title={alt} | ||
className={cn("absolute inset-0 w-full h-full", className)} | ||
allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" | ||
allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; web-share" | ||
allowFullScreen | ||
/> | ||
); | ||
}; | ||
|
||
YoutubeVideo.propTypes = { | ||
src: propTypes.string.isRequired, | ||
alt: propTypes.string.isRequired, | ||
className: propTypes.string, | ||
startTime: propTypes.number, | ||
isAutoPlay: propTypes.bool, | ||
isLoop: propTypes.bool, | ||
isMuted: propTypes.bool, | ||
}; | ||
|
||
export { YoutubeVideo }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
function ConvertMinutesToSeconds(time) { | ||
if (typeof time === "number") { | ||
return time; | ||
} else if (typeof time === "undefined") { | ||
return 0; | ||
} else if (typeof time !== "string") { | ||
throw new Error("Invalid time format " + typeof time); | ||
} | ||
// Split the input by colon | ||
const parts = time.split(":"); | ||
|
||
// Ensure we have two parts | ||
if (parts.length < 2) { | ||
return time; // Return the input if is seconds only | ||
} else if (parts.length > 2) { | ||
throw new Error("Invalid time format"); | ||
} | ||
|
||
// Extract minutes and seconds from the parts | ||
const minutes = parseInt(parts[0], 10); | ||
const seconds = parseInt(parts[1], 10); | ||
|
||
// Convert minutes to seconds and add to the seconds part | ||
return minutes * 60 + seconds; | ||
} | ||
|
||
export { ConvertMinutesToSeconds }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters