### Install Project Dependencies Source: https://github.com/gyanreyer/react-hover-video-player/blob/main/docs/CONTRIBUTING.md Installs all necessary project dependencies and sets up Husky commit hooks. This command should be run after cloning the forked repository. ```bash npm install ``` -------------------------------- ### Install React Hover Video Player Source: https://context7.com/gyanreyer/react-hover-video-player/llms.txt Installs the react-hover-video-player package using npm. This is the first step to using the library in a React project. ```bash npm install react-hover-video-player ``` -------------------------------- ### Run Documentation Development Server Source: https://github.com/gyanreyer/react-hover-video-player/blob/main/docs/CONTRIBUTING.md Starts a local development server to preview the documentation site. The site is built using VuePress and can be accessed at http://localhost:8080. ```bash npm run docs:dev ``` -------------------------------- ### React Hover Video Player loadingOverlay Prop Example Source: https://context7.com/gyanreyer/react-hover-video-player/llms.txt Demonstrates the `loadingOverlay` prop, which displays content during video buffering after playback initiation. This overlay appears above the `pausedOverlay` and provides buffering feedback, especially for slower connections. Includes a `loadingStateTimeout` prop example. ```jsx import HoverVideoPlayer from 'react-hover-video-player'; function VideoWithLoadingState() { return ( } loadingOverlay={
} loadingStateTimeout={300} /> ); } ``` -------------------------------- ### Run Development Playground Server Source: https://github.com/gyanreyer/react-hover-video-player/blob/main/docs/CONTRIBUTING.md Starts a local development server to test changes in a live demo environment. The playground is served from the `dev/index.tsx` file at http://localhost:8080. ```bash npm run dev ``` -------------------------------- ### React Hover Video Player pausedOverlay Prop Example Source: https://context7.com/gyanreyer/react-hover-video-player/llms.txt Shows how to use the `pausedOverlay` prop to display content, such as a thumbnail image, when the video is paused or loading. This overlay fades out when playback starts and reappears when paused. ```jsx import HoverVideoPlayer from 'react-hover-video-player'; function VideoWithThumbnail() { return ( } /> ); } ``` -------------------------------- ### React Hover Video Player videoSrc Prop Examples Source: https://context7.com/gyanreyer/react-hover-video-player/llms.txt Illustrates how to use the `videoSrc` prop, which accepts either a single video URL string or React nodes with multiple `` elements for format fallbacks. It's recommended to order multiple sources by ascending file size. ```jsx import HoverVideoPlayer from 'react-hover-video-player'; // Single source function SingleSource() { return ( ); } // Multiple sources with format fallbacks function MultipleSources() { return ( } /> ); } ``` -------------------------------- ### Handle Hover Start Event in React Hover Video Player Source: https://github.com/gyanreyer/react-hover-video-player/blob/main/docs/README.md The `onHoverStart` prop accepts a callback function that is executed when the user begins hovering over or touching the player's designated hover target. ```jsx { console.log('User just moused over or touched hover target.'); console.log('The video will now attempt to play.'); }} /> ``` -------------------------------- ### Delay Video Playback Start with React Hover Video Player Source: https://github.com/gyanreyer/react-hover-video-player/blob/main/docs/README.md The `playbackStartDelay` prop allows you to specify a delay in milliseconds before the video starts loading after a user begins hovering. This is useful for reducing server load when self-hosting many videos. It's recommended to use a loading overlay with this prop to provide visual feedback during the delay. ```jsx ``` -------------------------------- ### Set Playback Range Start for HoverVideoPlayer Source: https://github.com/gyanreyer/react-hover-video-player/blob/main/docs/README.md Configure the starting point for video playback using the `playbackRangeStart` prop. This prop accepts a number in seconds, specifying when the video should begin playing. If not provided, playback starts from the video's beginning. This is useful for previewing specific sections of longer videos. ```jsx ``` -------------------------------- ### React Hover Video Player hoverOverlay Prop Example Source: https://context7.com/gyanreyer/react-hover-video-player/llms.txt Illustrates the `hoverOverlay` prop, which renders content on top of the playing video during hover. This is useful for displaying supplementary information like titles or calls-to-action while the video plays in the background. ```jsx import HoverVideoPlayer from 'react-hover-video-player'; function VideoWithHoverInfo() { return ( } hoverOverlay={

Video Title

Click to watch the full video

} /> ); } ``` -------------------------------- ### Access Video Element with videoRef Prop in React Source: https://context7.com/gyanreyer/react-hover-video-player/llms.txt Illustrates how to use the `videoRef` prop to get a React ref to the underlying video element. This allows direct manipulation, such as adjusting playback rate or adding custom event listeners. ```jsx import { useRef, useEffect } from 'react'; import HoverVideoPlayer from 'react-hover-video-player'; function SlowMotionVideo() { const videoRef = useRef(null); useEffect(() => { if (videoRef.current) { // Set video to play at half speed videoRef.current.playbackRate = 0.5; } }, []); return ( } /> ); } ``` -------------------------------- ### Show Loading Overlay Content Source: https://github.com/gyanreyer/react-hover-video-player/blob/main/docs/README.md The loadingOverlay prop enables you to display custom content when the video takes too long to start playing after a user attempts to play it. This overlay appears on top of the pausedOverlay and is useful for providing feedback to users with slower internet connections. The duration before this overlay appears can be controlled by the loadingStateTimeout prop. ```jsx Loading...
} /> ``` -------------------------------- ### Set Video Player Sizing Mode to Container Source: https://github.com/gyanreyer/react-hover-video-player/blob/main/docs/README.md The sizingMode prop controls how the video player's content is sized. Setting it to 'container' makes the video and overlays expand to fill the component's outer div. This example demonstrates using 'container' mode with custom styling to maintain a 16:9 aspect ratio. ```jsx ``` -------------------------------- ### Disable Default Event Handling in React Hover Video Player Source: https://github.com/gyanreyer/react-hover-video-player/blob/main/docs/README.md The `disableDefaultEventHandling` prop, when set to true, stops the player from automatically playing on mouse enter/touch start and pausing on mouse leave/touch start outside the player. This is useful for custom event implementations. ```jsx const [isVideoPlaying, setIsVideoPlaying] = useState(false); ...
setIsVideoPlaying(!isVideoPlaying)} >
``` -------------------------------- ### Set Loading State Timeout for Hover Video Player Source: https://github.com/gyanreyer/react-hover-video-player/blob/main/docs/README.md Determines the delay in milliseconds before the loading state is displayed if the video doesn't start playing immediately. This prevents premature loading indicators for quick-starting videos. ```jsx Loading...} // We should only show the loading state if the video takes // more than 1 full second to start after attempting to play loadingStateTimeout={1000} /> ``` -------------------------------- ### Display Paused Overlay Content Source: https://github.com/gyanreyer/react-hover-video-player/blob/main/docs/README.md The pausedOverlay prop allows you to render custom content over the video when it is paused or loading. This content fades out when the video starts playing. A common use case is displaying a thumbnail image, ensuring it covers the video's dimensions. ```jsx } /> ``` -------------------------------- ### Unload Video When Paused with React Hover Video Player Source: https://github.com/gyanreyer/react-hover-video-player/blob/main/docs/README.md The `unloadVideoOnPaused` prop, when set to true, ensures that video assets are completely unloaded when the video is not playing. This helps mitigate performance issues caused by multiple large videos loading in the background. Note that this may slightly increase video start times on repeat plays and requires a paused overlay for a seamless user experience. ```jsx ``` -------------------------------- ### Build Project for Production Source: https://github.com/gyanreyer/react-hover-video-player/blob/main/docs/CONTRIBUTING.md Compiles and bundles the project for production deployment. This command is part of the release process. ```bash npm run build:prod ``` -------------------------------- ### Handle Video Events with onHoverStart and onHoverEnd Callbacks in React Source: https://context7.com/gyanreyer/react-hover-video-player/llms.txt Demonstrates using `onHoverStart` and `onHoverEnd` callbacks to react to user hover events on the player. These are useful for analytics or coordinating UI changes with video playback. ```jsx import { useState } from 'react'; import HoverVideoPlayer from 'react-hover-video-player'; function VideoWithAnalytics() { const [hoverCount, setHoverCount] = useState(0); return (

Hover count: {hoverCount}

{ console.log('Video hover started'); setHoverCount(prev => prev + 1); }} onHoverEnd={() => { console.log('Video hover ended'); }} pausedOverlay={ } />
); } ``` -------------------------------- ### Provide Multiple Video Sources Source: https://github.com/gyanreyer/react-hover-video-player/blob/main/docs/README.md Illustrates how to provide multiple video sources for the HoverVideoPlayer component using `` elements within a React fragment. It's recommended to order sources by ascending file size. ```jsx ) /> ``` -------------------------------- ### onHoverStart Source: https://github.com/gyanreyer/react-hover-video-player/blob/main/docs/README.md Callback function fired when the user hovers over the player's hover target. ```APIDOC ## onHoverStart ### Description Accepts a callback function which will be fired when the user hovers on the player's [hover target](#hovertarget). ### Type `function` ### Default `null` ### Request Example ```jsx { console.log('User just moused over or touched hover target.'); console.log('The video will now attempt to play.'); }} /> ``` ``` -------------------------------- ### Basic Usage of HoverVideoPlayer Component Source: https://github.com/gyanreyer/react-hover-video-player/blob/main/docs/README.md Demonstrates the basic implementation of the HoverVideoPlayer component in React. It shows how to provide the video source and optional loading and paused state overlays. ```jsx import HoverVideoPlayer from 'react-hover-video-player'; function MyComponent() { return ( } loadingOverlay={
} /> ); } ``` -------------------------------- ### Overlay Transition and Loading State Props Source: https://github.com/gyanreyer/react-hover-video-player/blob/main/docs/README.md Configure the transition duration for overlays and the timeout for loading states. ```APIDOC ## overlayTransitionDuration ### Description Accepts the number of milliseconds for the paused and loading overlays to fade in and out as the player's state changes. ### Method N/A (Prop) ### Endpoint N/A (Prop) ### Parameters #### Path Parameters N/A #### Query Parameters N/A #### Request Body - **overlayTransitionDuration** (number) - Required - The duration in milliseconds for overlay transitions. ### Request Example ```jsx Paused!
} overlayTransitionDuration={500} /> ``` ### Response #### Success Response (200) N/A #### Response Example N/A --- ## loadingStateTimeout ### Description Accepts the number of milliseconds the player should wait before showing a loading state if the video is not able to play immediately. ### Method N/A (Prop) ### Endpoint N/A (Prop) ### Parameters #### Path Parameters N/A #### Query Parameters N/A #### Request Body - **loadingStateTimeout** (number) - Required - The timeout in milliseconds before showing the loading state. ### Request Example ```jsx Loading...} loadingStateTimeout={1000} /> ``` ### Response #### Success Response (200) N/A #### Response Example N/A ``` -------------------------------- ### Provide Single Video Source Source: https://github.com/gyanreyer/react-hover-video-player/blob/main/docs/README.md Shows how to specify a single video source for the HoverVideoPlayer component using a string URL. ```jsx ``` -------------------------------- ### Customizing Video Player Styles with Props Source: https://context7.com/gyanreyer/react-hover-video-player/llms.txt Demonstrates how to apply custom styles to the container, video element, and overlay wrappers of the HoverVideoPlayer component using className and style props. This allows for detailed visual customization of the player's appearance. ```jsx import HoverVideoPlayer from 'react-hover-video-player'; function FullyStyledVideo() { return ( } // Loading overlay wrapper styling loadingOverlayWrapperClassName="loading-wrapper" loadingOverlayWrapperStyle={{ backgroundColor: 'rgba(0,0,0,0.5)' }} loadingOverlay={
Loading...
} // Hover overlay wrapper styling hoverOverlayWrapperClassName="hover-wrapper" hoverOverlayWrapperStyle={{ backgroundColor: 'rgba(0,0,0,0.7)' }} hoverOverlay={
Now Playing
} // Transition timing overlayTransitionDuration={500} loadingStateTimeout={300} /> ); } ``` -------------------------------- ### Basic React Hover Video Player Usage Source: https://context7.com/gyanreyer/react-hover-video-player/llms.txt Demonstrates the simplest implementation of the HoverVideoPlayer component. It requires only the video source URL and automatically handles hover, playback, and pause states. ```jsx import HoverVideoPlayer from 'react-hover-video-player'; function VideoThumbnail() { return ( ); } ``` -------------------------------- ### Optimize Video Performance with Unload, Delay, and Preload Props in React Source: https://context7.com/gyanreyer/react-hover-video-player/llms.txt Shows how to optimize video performance using `unloadVideoOnPaused`, `playbackStartDelay`, and `preload` props. These props help reduce memory usage, server load, and control data loading before playback. ```jsx import HoverVideoPlayer from 'react-hover-video-player'; function OptimizedVideoGallery() { const videos = [ { src: 'video1.mp4', thumb: 'thumb1.jpg' }, { src: 'video2.mp4', thumb: 'thumb2.jpg' }, { src: 'video3.mp4', thumb: 'thumb3.jpg' }, ]; return (
{videos.map((video, index) => ( } loadingOverlay={
Loading...
} /> ))}
); } ``` -------------------------------- ### Convert Video Recording to GIF with ffmpeg Source: https://github.com/gyanreyer/react-hover-video-player/blob/main/docs/CONTRIBUTING.md Converts a video recording to a GIF file with optimized frame rate, scaling, and color palette. This command is recommended for creating documentation GIFs. ```bash ffmpeg -i path/to/original-recording.mp4 -vf "fps=10,scale=1024:-1:flags=lanczos,split[s0][s1];[s0]palettegen[p];[s1][p]paletteuse" output/demo.gif ``` -------------------------------- ### Control Sizing with sizingMode Prop Source: https://context7.com/gyanreyer/react-hover-video-player/llms.txt The `sizingMode` prop dictates how the player's content is scaled. Available options include 'video' (default), 'overlay', 'container', and 'manual', offering flexibility in how the video and its overlays adapt to different layouts. ```jsx // Container-based sizing with fixed aspect ratio function FixedAspectRatioVideo() { return ( } /> ); } // Overlay-based sizing function OverlaySizedVideo() { return ( } /> ); } ``` -------------------------------- ### videoRef Source: https://github.com/gyanreyer/react-hover-video-player/blob/main/docs/README.md Exposes a ref to the video element, allowing direct access for advanced customization. ```APIDOC ## videoRef ### Description Can be used to expose a ref to the video element rendered by HoverVideoPlayer. This is useful if you need to directly access the video element to extend its behavior in some way, but beware that any changes you make could produce unexpected behavior from the component. ### Type `React.Ref` ### Default `null` ### Request Example ```jsx const hoverVideoRef = useRef(); useEffect(() => { const videoElement = hoverVideoRef.current; videoElement.playbackRate = 2; }, []); return ; ``` ``` -------------------------------- ### volume Source: https://github.com/gyanreyer/react-hover-video-player/blob/main/docs/README.md Sets the volume for the video's audio, ranging from 0 to 1. Requires `muted` to be `false`. ```APIDOC ## volume ### Description Accepts a number on a scale from 0-1 for the volume that the video's audio should play at. Note that this will only work if the [muted](#muted) prop is also set to `false`. ### Type `number` ### Default `1` ### Request Example ```jsx ``` ``` -------------------------------- ### Run All Automated Tests Source: https://github.com/gyanreyer/react-hover-video-player/blob/main/docs/CONTRIBUTING.md Executes all automated tests using Playwright. Ensure all tests pass before submitting changes. This command can also accept a specific test file name as an argument to run only that file. ```bash npm run test ``` ```bash npm run test -- videoSrc.spec.ts ``` -------------------------------- ### Hover Overlay Prop Source: https://github.com/gyanreyer/react-hover-video-player/blob/main/docs/README.md Define custom content to be displayed over the video during hover or focus states. ```APIDOC ## hoverOverlay ### Description An optional prop that accepts any renderable content to be displayed over the video while the player is active from a hover/touch event or when the `focused` prop is `true`. This overlay takes the highest ordering priority. ### Method N/A (Prop) ### Endpoint N/A (Prop) ### Parameters #### Path Parameters N/A #### Query Parameters N/A #### Request Body - **hoverOverlay** (node) - Optional - Renderable content for the hover overlay. ### Request Example ```jsx

Video Title

Here is a short description of the video.

} /> ``` ### Response #### Success Response (200) N/A #### Response Example N/A ``` -------------------------------- ### Display Custom Content with Hover Overlay in Video Player Source: https://github.com/gyanreyer/react-hover-video-player/blob/main/docs/README.md Allows rendering custom content on top of the video when the player is active due to hover, touch, or focus. This overlay has the highest z-index and can be used to display titles, descriptions, or interactive elements. ```jsx

Video Title

Here is a short description of the video. You can still see the video playing underneath this overlay. Click here to read more

} /> ``` -------------------------------- ### Set Overlay Transition Duration for Hover Video Player Source: https://github.com/gyanreyer/react-hover-video-player/blob/main/docs/README.md Configures the time in milliseconds for the paused and loading overlays to fade in and out. This ensures a seamless user experience as the player's state changes. ```jsx Paused!} // It should take 500ms for the pausedOverlay to fade out when // the video plays and fade back in when the video pauses overlayTransitionDuration={500} /> ``` -------------------------------- ### loop Source: https://github.com/gyanreyer/react-hover-video-player/blob/main/docs/README.md Toggles whether the video should loop when it reaches the end. ```APIDOC ## loop ### Description Accepts a boolean value which toggles whether or not the video should loop when it reaches the end. ### Type `boolean` ### Default `true` ### Request Example ```jsx ``` ``` -------------------------------- ### restartOnPaused Source: https://github.com/gyanreyer/react-hover-video-player/blob/main/docs/README.md Toggles whether the video should restart from the beginning when paused. ```APIDOC ## restartOnPaused ### Description Accepts a boolean value which will toggle whether the video should be reset to the start every time it is paused or resume from the previous time it was at. ### Type `boolean` ### Default `false` ### Request Example ```jsx ``` ``` -------------------------------- ### Set Video Preload to Metadata Source: https://github.com/gyanreyer/react-hover-video-player/blob/main/docs/README.md The preload prop corresponds to the HTML Video element's preload attribute, determining how much data is loaded before playback. Setting it to 'metadata' ensures only the video's metadata (dimensions, duration) is loaded initially. This is useful for performance but may require a paused overlay in Safari. ```jsx ``` -------------------------------- ### Programmatic Video Control with focused Prop Source: https://context7.com/gyanreyer/react-hover-video-player/llms.txt The `focused` prop offers direct control over video playback, overriding the default hover behavior. Setting it to `true` forces playback, while `false` reverts to standard hover interactions. ```jsx import { useState } from 'react'; import HoverVideoPlayer from 'react-hover-video-player'; function ControlledVideoPlayer() { const [isPlaying, setIsPlaying] = useState(false); return (
} />
); } ``` -------------------------------- ### Apply Custom Styling to HoverVideoPlayer Source: https://github.com/gyanreyer/react-hover-video-player/blob/main/docs/README.md Customize the appearance of the `HoverVideoPlayer` component using various props that accept class names and style objects. These props allow targeted styling for the outer container, overlay wrappers, and the video element itself, providing flexibility in UI integration. ```jsx ``` -------------------------------- ### Define Playback Segment with playbackRange Props Source: https://context7.com/gyanreyer/react-hover-video-player/llms.txt The `playbackRangeStart` and `playbackRangeEnd` props allow you to specify a precise segment of the video for playback, measured in seconds. This is ideal for showcasing specific parts of longer videos without altering the original file. ```jsx import HoverVideoPlayer from 'react-hover-video-player'; function VideoPreviewClip() { return ( } /> ); } ``` -------------------------------- ### Define Hover Target Element for Video Player Source: https://github.com/gyanreyer/react-hover-video-player/blob/main/docs/README.md Specifies the DOM element, a function returning a DOM element, or a React ref that will trigger the video playback on hover or touch. If not provided, the component's container acts as the target. ```jsx // Passing a function that returns a DOM node document.getElementById("hover-target")} /> ... // Using a React ref const wrapperLinkRef = useRef(); ... // Passing a DOM node // PLEASE BEWARE THAT THIS CAN BE UNSAFE: Only do this if you are confident that the element // will always already exist on the DOM before this component is rendered. ``` -------------------------------- ### Implement Closed Captions with videoCaptions Source: https://github.com/gyanreyer/react-hover-video-player/blob/main/docs/README.md The videoCaptions prop allows you to add closed captions to your video player. It accepts a React node containing one or more elements. Each element specifies the source (src), language (srcLang), and title (label) of the caption file. You can include multiple tracks by wrapping them in a React fragment. ```tsx ) /> ``` ```jsx ) controls /> ``` -------------------------------- ### Control Video Audio with Muted and Volume Props in React Source: https://context7.com/gyanreyer/react-hover-video-player/llms.txt Demonstrates how to control video audio using the `muted` and `volume` props in React. Videos are muted by default. If unmuted playback is blocked, it falls back to muted playback. ```jsx import HoverVideoPlayer from 'react-hover-video-player'; function VideoWithAudio() { return ( } /> ); } ``` -------------------------------- ### Implementing Click-to-Play with Disabled Hover Events Source: https://context7.com/gyanreyer/react-hover-video-player/llms.txt Shows how to disable the default hover event handling of the HoverVideoPlayer using the `disableDefaultEventHandling` prop. This allows for custom playback control, such as implementing a click-to-play interface managed by the `focused` prop. ```jsx import { useState } from 'react'; import HoverVideoPlayer from 'react-hover-video-player'; function ClickToPlayVideo() { const [isPlaying, setIsPlaying] = useState(false); return (
setIsPlaying(!isPlaying)} style={{ cursor: 'pointer' }}>
{isPlaying ? '⏸' : '▶'}
} /> ); } ``` -------------------------------- ### Hover Event Handling Props Source: https://github.com/gyanreyer/react-hover-video-player/blob/main/docs/README.md Control the target element for hover events and whether the player should be forced to play. ```APIDOC ## hoverTarget ### Description Accepts a DOM node, a function that returns a DOM node, or a React ref to an element. The component will apply default event handling to this target element so the video plays on hover/touch. If not provided, the component's container `
` is used. ### Method N/A (Prop) ### Endpoint N/A (Prop) ### Parameters #### Path Parameters N/A #### Query Parameters N/A #### Request Body - **hoverTarget** (Node | function | React.RefObject) - Optional - The element to use as the hover target. ### Request Example ```jsx // Using a React ref const wrapperLinkRef = useRef(); ``` ### Response #### Success Response (200) N/A #### Response Example N/A --- ## focused ### Description Accepts a boolean value which, if true, will force the video player to play regardless of other user interactions. Useful for custom behavior outside of standard interactions. ### Method N/A (Prop) ### Endpoint N/A (Prop) ### Parameters #### Path Parameters N/A #### Query Parameters N/A #### Request Body - **focused** (boolean) - Optional - Forces the video player to play. ### Request Example ```jsx const [isVideoPlaying, setIsVideoPlaying] = useState(false); ``` ### Response #### Success Response (200) N/A #### Response Example N/A ``` -------------------------------- ### onHoverEnd Source: https://github.com/gyanreyer/react-hover-video-player/blob/main/docs/README.md Callback function fired when the user stops hovering over the player's hover target. ```APIDOC ## onHoverEnd ### Description Accepts a callback function which will be fired when the user stops hovering on the player's [hover target](#hovertarget). ### Type `function` ### Default `null` ### Request Example ```jsx { console.log('User just moused out of or touched outside of hover target.'); console.log('The video will now stop playing.'); }} /> ``` ``` -------------------------------- ### Migrate videoSrc prop from array of config objects to fragment of source elements (React) Source: https://github.com/gyanreyer/react-hover-video-player/blob/main/docs/BREAKING.md This snippet shows the migration of the `videoSrc` prop from an array of configuration objects to a fragment containing multiple `` elements. Each object in the original array is converted into a `` element with its `src` and `type` attributes. This is required as the `videoSrc` prop no longer supports arrays of config objects. ```diff import HoverVideoPlayer from 'react-hover-video-player'; function MyComponent() { return ( + + + + } /> ); } ``` -------------------------------- ### Enable Video Controls with React Hover Video Player Source: https://github.com/gyanreyer/react-hover-video-player/blob/main/docs/README.md The `controls` prop, when set to true, enables the default browser video playback controls for the video player. This provides users with standard playback functionalities. ```jsx ``` -------------------------------- ### Add Closed Captions with videoCaptions Prop Source: https://context7.com/gyanreyer/react-hover-video-player/llms.txt The `videoCaptions` prop allows the integration of closed captions using `` elements for improved accessibility. When utilizing multiple tracks or non-default captions, ensure the `controls` prop is enabled for user selection. ```jsx import HoverVideoPlayer from 'react-hover-video-player'; function VideoWithCaptions() { return ( } controls /> ); } ``` -------------------------------- ### Configure CORS with crossOrigin Source: https://github.com/gyanreyer/react-hover-video-player/blob/main/docs/README.md The crossOrigin prop configures how the video element handles CORS requests, directly mapping to the HTML Video element's crossorigin attribute. It can be set to 'anonymous' to send cross-origin requests without credentials, or 'use-credentials' to send them with credentials. 'anonymous' is a common setting when encountering CORS issues. ```jsx ``` -------------------------------- ### muted Source: https://github.com/gyanreyer/react-hover-video-player/blob/main/docs/README.md Toggles whether the video should play with sound. Be aware of browser autoplay policies. ```APIDOC ## muted ### Description Accepts a boolean value which toggles whether or not the video should be muted. Note that if the video is unmuted, you may encounter issues with [browser autoplay policies](https://developer.chrome.com/blog/autoplay/) blocking the video from playing with sound. This is an unfortunate limitation stemming from the fact that modern browsers will block playing audio until the user has "interacted" with the page by doing something like clicking or tapping anywhere at least once. If playback is initially blocked for an unmuted video, the component will fall back by muting the video and attempting to play again without audio; if the user clicks on the page, the video will be unmuted again and continue playing. ### Type `boolean` ### Default `true` ### Request Example ```jsx ``` ``` -------------------------------- ### Migrate videoCaptions prop from config objects to track elements (React) Source: https://github.com/gyanreyer/react-hover-video-player/blob/main/docs/BREAKING.md This snippet illustrates the migration of the `videoCaptions` prop from an array of caption track configuration objects to a fragment containing multiple `` elements. Properties like `src`, `srcLang`, `label`, `kind`, and `default` from the config objects are directly mapped to attributes on the `` elements. This change is due to the deprecation of config objects for caption tracks. ```diff import HoverVideoPlayer from 'react-hover-video-player'; function MyComponent() { return ( + + + + } /> ); } ``` -------------------------------- ### Customize Video Controls List with React Hover Video Player Source: https://github.com/gyanreyer/react-hover-video-player/blob/main/docs/README.md The `controlsList` prop accepts a string to exclude specific buttons from the video's playback controls, such as 'nodownload' or 'nofullscreen'. Note that browser support for this feature may vary. ```jsx ``` -------------------------------- ### Migrate videoSrc prop from config object to source element (React) Source: https://github.com/gyanreyer/react-hover-video-player/blob/main/docs/BREAKING.md This snippet demonstrates how to migrate the `videoSrc` prop from a configuration object to a single `` element. The `src` and `type` properties from the config object map directly to the attributes of the `` element. This change is necessary because the `videoSrc` prop no longer accepts config objects. ```diff import HoverVideoPlayer from 'react-hover-video-player'; function MyComponent() { return ( + } /> ); } ``` -------------------------------- ### Force Video Player to Play with Focused Prop Source: https://github.com/gyanreyer/react-hover-video-player/blob/main/docs/README.md Forces the video player to play regardless of user interactions when set to true. This is useful for implementing custom playback controls or ensuring video playback in specific scenarios. ```jsx const [isVideoPlaying, setIsVideoPlaying] = useState(false); ... ``` -------------------------------- ### Set Video Volume in React Hover Video Player Source: https://github.com/gyanreyer/react-hover-video-player/blob/main/docs/README.md The `volume` prop accepts a number between 0 and 1 to set the audio playback volume. This prop only functions when the `muted` prop is set to `false`. ```jsx ``` -------------------------------- ### Custom Hover Trigger with hoverTarget Prop Source: https://context7.com/gyanreyer/react-hover-video-player/llms.txt The `hoverTarget` prop enables the use of an alternative DOM element as the hover trigger for the video player. This is useful for scenarios where hovering over a parent element or an external component should initiate video playback. ```jsx import { useRef } from 'react'; import HoverVideoPlayer from 'react-hover-video-player'; function CardWithVideoPreview() { const cardRef = useRef(null); return ( } />

Video Title

Hover anywhere on this card to preview the video

); } ``` -------------------------------- ### disableDefaultEventHandling Source: https://github.com/gyanreyer/react-hover-video-player/blob/main/docs/README.md Disables the player's default event handling for mouse and touch interactions, allowing for custom behavior implementation. ```APIDOC ## disableDefaultEventHandling ### Description Accepts a boolean value which, if true, will disable the player's default built-in event handling where `onMouseEnter` and `onTouchStart` events play the video and `onMouseLeave` events and `touchStart` events outside of the player pause the video. This can be useful if you want to build a fully custom implementation of the player's behavior using the [focused](#focused) prop. ### Type `boolean` ### Default `false` ### Request Example ```jsx ``` ```