Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ export default function App() {
| `height` | `string \| number` | `"auto"` | Height of player |
| `className` | `string` | `""` | Custom CSS class |
| `color` | `string` | `"#ff0000"` | Primary color (progress, volume, etc.) |
| `skipSeconds` | `number` | `10` | Custom forward and backward skip value (in seconds)

---

Expand Down
25 changes: 12 additions & 13 deletions src/ReactNextPlayer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export interface ReactNextPlayerProps {
height?: string | number;
className?: string;
color?: string;
skipSeconds?: number;
onPlay?: () => void;
onPause?: () => void;
onTimeUpdate?: (currentTime: number) => void;
Expand All @@ -31,6 +32,7 @@ const ReactNextPlayer: React.FC<ReactNextPlayerProps> = ({
height = "auto",
className = "",
color = "#ff0000",
skipSeconds = 10,
onPlay,
onPause,
onTimeUpdate,
Expand Down Expand Up @@ -115,19 +117,19 @@ const ReactNextPlayer: React.FC<ReactNextPlayerProps> = ({
if (videoRef.current) {
videoRef.current.currentTime = Math.max(
0,
videoRef.current.currentTime - 10
videoRef.current.currentTime - skipSeconds
);
}
}, []);
}, [skipSeconds]);

const handleSkipForward = useCallback(() => {
if (videoRef.current) {
videoRef.current.currentTime = Math.min(
duration,
videoRef.current.currentTime + 10
videoRef.current.currentTime + skipSeconds
);
}
}, [duration]);
}, [duration, skipSeconds]);

const handleTimeUpdate = useCallback(() => {
if (videoRef.current) {
Expand Down Expand Up @@ -730,9 +732,8 @@ const ReactNextPlayer: React.FC<ReactNextPlayerProps> = ({

<div
ref={playerRef}
className={`react-vid-player ${className} ${
isFullscreen ? "fullscreen" : ""
}`}
className={`react-vid-player ${className} ${isFullscreen ? "fullscreen" : ""
}`}
style={
{
width,
Expand Down Expand Up @@ -765,9 +766,8 @@ const ReactNextPlayer: React.FC<ReactNextPlayerProps> = ({

{/* Center play/pause overlay - only show when paused or on hover */}
<div
className={`center-overlay ${
!isPlaying || (showControls && isHovering) ? "visible" : ""
}`}
className={`center-overlay ${!isPlaying || (showControls && isHovering) ? "visible" : ""
}`}
onClick={handlePlayPause}
>
{isPlaying ? (
Expand Down Expand Up @@ -798,9 +798,8 @@ const ReactNextPlayer: React.FC<ReactNextPlayerProps> = ({

{controls && (
<div
className={`video-controls ${
showControls || !isPlaying ? "visible" : "hidden"
}`}
className={`video-controls ${showControls || !isPlaying ? "visible" : "hidden"
}`}
>
<div className="progress-container" onClick={handleProgressClick}>
<div className="progress-bar" ref={progressBarRef}>
Expand Down