()
| 258 | // Always start playback from the beginning of the seekable range. |
| 259 | let hasSeekedToStart = false; |
| 260 | const seekToStart = () => { |
| 261 | if (hasSeekedToStart) return; |
| 262 | try { |
| 263 | let target = 0; |
| 264 | if (video.seekable && video.seekable.length > 0) { |
| 265 | target = video.seekable.start(0); |
| 266 | } |
| 267 | // Only apply if we're not already at/near the start. Avoid |
| 268 | // setting currentTime when the video has no duration yet. |
| 269 | if ( |
| 270 | Number.isFinite(target) && |
| 271 | Math.abs((video.currentTime || 0) - target) > 0.25 |
| 272 | ) { |
| 273 | video.currentTime = target; |
| 274 | } |
| 275 | hasSeekedToStart = true; |
| 276 | } catch { |
| 277 | // ignore |
| 278 | } |
| 279 | }; |
| 280 | |
| 281 | const handleLoadStart = () => setIsLoading(true); |
| 282 | const handleLoadedMetadata = () => { |
no test coverage detected