Commit e26ef4f
authored
fix(player): improve play/pause button reliability (#141)
* fix(player): improve play/pause button reliability
Fix intermittent play/pause failures by implementing state synchronization,
optimistic updates, and delayed verification mechanisms.
## Root Cause
- requestTogglePlay relied on videoController.isPaused() which could be
out of sync with internal state
- Async play() operations could fail without proper error recovery
- State inconsistencies between video element and orchestrator context
## Solution
- Use internal context state as authoritative source for play/pause decisions
- Add syncPlaybackState() method to detect and fix state mismatches
- Implement optimistic updates with failure rollback
- Add delayed verification and retry mechanisms
- Enhance error handling for DOMExceptions
## Changes
- PlayerOrchestrator: Add state sync, optimistic updates, retry logic
- usePlayerCommands: Add detailed debugging logs and result verification
- Tests: Add 19 comprehensive test cases covering all scenarios
## Test Coverage
- 47 total test cases (100% pass rate)
- State synchronization scenarios
- Async operation handling
- Error recovery mechanisms
- Edge cases and boundary conditions
- Real usage scenarios (shortcuts, browser limitations)
Resolves the issue where play/pause would occasionally fail to resume
playback via keyboard shortcuts, requiring mouse click to recover.
* Update src/renderer/src/pages/player/engine/__tests__/PlayerOrchestrator.playback-reliability.test.ts1 parent 8923df9 commit e26ef4f
4 files changed
Lines changed: 516 additions & 11 deletions
File tree
- src/renderer/src/pages/player
- engine
- __tests__
- hooks
Lines changed: 149 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
249 | 249 | | |
250 | 250 | | |
251 | 251 | | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
252 | 267 | | |
253 | | - | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
254 | 286 | | |
255 | 287 | | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
256 | 294 | | |
257 | 295 | | |
258 | 296 | | |
| |||
265 | 303 | | |
266 | 304 | | |
267 | 305 | | |
268 | | - | |
269 | | - | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
270 | 347 | | |
271 | 348 | | |
272 | 349 | | |
| |||
278 | 355 | | |
279 | 356 | | |
280 | 357 | | |
281 | | - | |
282 | | - | |
283 | | - | |
284 | | - | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
285 | 386 | | |
286 | 387 | | |
287 | 388 | | |
| |||
514 | 615 | | |
515 | 616 | | |
516 | 617 | | |
| 618 | + | |
| 619 | + | |
| 620 | + | |
| 621 | + | |
| 622 | + | |
| 623 | + | |
| 624 | + | |
| 625 | + | |
| 626 | + | |
| 627 | + | |
| 628 | + | |
| 629 | + | |
| 630 | + | |
| 631 | + | |
| 632 | + | |
| 633 | + | |
| 634 | + | |
| 635 | + | |
| 636 | + | |
| 637 | + | |
| 638 | + | |
| 639 | + | |
| 640 | + | |
| 641 | + | |
| 642 | + | |
| 643 | + | |
| 644 | + | |
| 645 | + | |
| 646 | + | |
| 647 | + | |
| 648 | + | |
| 649 | + | |
| 650 | + | |
| 651 | + | |
| 652 | + | |
| 653 | + | |
| 654 | + | |
| 655 | + | |
| 656 | + | |
| 657 | + | |
| 658 | + | |
517 | 659 | | |
518 | 660 | | |
519 | 661 | | |
| |||
0 commit comments