screen_rotation
Copied to Clipboard
<!DOCTYPE html> <html> <head> <meta charset="UTF-8" /> <script src="https://cdnjs.cloudflare.com/ajax/libs/react/17.0.2/umd/react.development.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/react-dom/17.0.2/umd/react-dom.development.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/babel-standalone/6.26.0/babel.min.js"></script> </head> <body> <div id="app"></div> <script type="text/babel"> const {useRef} = React; function App() { const videoRef = useRef(null); const handleVideoEnd = () => { // This function will be called when the video ends // You can perform any actions you want here console.log('Video has ended'); // Restart the video when it ends if (videoRef.current) { videoRef.current.play(); } }; return ( <div className='container'> <h3>React Js Restart Video when it ends</h3> <video controls ref={videoRef} onEnded={handleVideoEnd} src="https://www.w3schools.com/tags/movie.mp4" /> </div> ); } ReactDOM.render(<App />, document.getElementById('app')); </script> <style> /* Container */ .container { font-family: Arial, sans-serif; max-width: 800px; margin: 0 auto; padding: 20px; border-radius: 8px; box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1); text-align: center; } video { max-width: 100%; height: auto; border: 4px solid #333; border-radius: 10px; } /* Style the controls */ video::-webkit-media-controls-panel { background-color: rgba(0, 0, 0, 0.6); color: #fff; border-radius: 10px; } /* Style the progress bar */ video::-webkit-media-controls-current-time-display, video::-webkit-media-controls-time-remaining-display { color: #fff; font-size: 14px; } /* Style the play/pause button */ video::-webkit-media-controls-play-button, video::-webkit-media-controls-pause-button { color: #fff; font-size: 24px; background-color: #ff5722; border-radius: 50%; padding: 10px; } video::-webkit-media-controls-volume-slider::-webkit-slider-thumb { background-color: #ff5722; width: 16px; height: 16px; } /* Style the fullscreen button */ video::-webkit-media-controls-fullscreen-button { color: #fff; font-size: 20px; background-color: #ff5722; border-radius: 50%; padding: 10px; } /* Style the video progress bar */ video::-webkit-media-controls-seek-back-button, video::-webkit-media-controls-seek-forward-button { background-color: #ff5722; color: #fff; border-radius: 50%; padding: 6px; } video::-webkit-media-controls-rewind-button, video::-webkit-media-controls-return-to-realtime-button { background-color: #ff5722; color: #fff; border-radius: 50%; padding: 6px; } </style> </body> </html>