import React, { useState, useEffect } from 'react'; import '../styles/IOSPlayPrompt.css'; interface MobilePlayPromptProps { videoRef: React.RefObject; onPlay: () => void; } const MobilePlayPrompt: React.FC = ({ videoRef, onPlay }) => { const [isVisible, setIsVisible] = useState(false); // Check if the device is mobile useEffect(() => { const checkIsMobile = () => { // More comprehensive check for mobile/tablet devices return /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini|Mobile|mobile|CriOS/i.test( navigator.userAgent ); }; // Always show for mobile devices on each visit const isMobile = checkIsMobile(); setIsVisible(isMobile); }, []); // Close the prompt when video plays useEffect(() => { const video = videoRef.current; if (!video) return; const handlePlay = () => { // Just close the prompt when video plays setIsVisible(false); }; video.addEventListener('play', handlePlay); return () => { video.removeEventListener('play', handlePlay); }; }, [videoRef]); const handlePlayClick = () => { onPlay(); // Prompt will be closed by the play event handler }; if (!isVisible) return null; return (
{/*

Mobile Device Notice

For the best video editing experience on mobile devices, you need to play the video first before using the timeline controls.

Please follow these steps:

  1. Tap the button below to start the video
  2. After the video starts, you can pause it
  3. Then you'll be able to use all timeline controls
*/}
); }; export default MobilePlayPrompt;