Commit adbec63
authored
feat(client): expose blocked autoplay audio state and explicit resume API (#2187)
### 💡 Overview
This PR introduces a way to recover when incoming audio is blocked by
browser autoplay rules. It tracks blocked audio, exposes that state to
consumers, and adds `call.resumeAudio()` so they can retry playback
after a user interaction. It also includes a test for the case where the
audio stream is removed before playback resumes.
### 📝 Implementation notes
- invoke `call.resumeAudio()` for explicit retry from a user gesture
- use `useIsAutoplayBlocked()` from call state hooks to detect blocked
incoming audio
🎫 Ticket:
https://linear.app/stream/issue/REACT-941/audio-autoplay-policy-observable
📑 Docs: GetStream/docs-content#1155
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit
* **New Features**
* Detects browser autoplay-blocked audio and exposes a boolean
observable to track it.
* Provides a public resume operation to retry playback for blocked audio
elements.
* Adds a React hook to surface autoplay-blocked state for UI
integration.
* **Tests**
* Adds tests covering detection, recovery, and cleanup of
autoplay-blocked audio flows.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->1 parent 5c642ce commit adbec63
4 files changed
Lines changed: 211 additions & 1 deletion
File tree
- packages
- client/src
- helpers
- __tests__
- react-bindings/src/hooks
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2922 | 2922 | | |
2923 | 2923 | | |
2924 | 2924 | | |
| 2925 | + | |
| 2926 | + | |
| 2927 | + | |
| 2928 | + | |
| 2929 | + | |
| 2930 | + | |
| 2931 | + | |
2925 | 2932 | | |
2926 | 2933 | | |
2927 | 2934 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
79 | 79 | | |
80 | 80 | | |
81 | 81 | | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
82 | 116 | | |
83 | 117 | | |
84 | 118 | | |
| |||
136 | 170 | | |
137 | 171 | | |
138 | 172 | | |
| 173 | + | |
139 | 174 | | |
140 | 175 | | |
141 | 176 | | |
| |||
575 | 610 | | |
576 | 611 | | |
577 | 612 | | |
578 | | - | |
| 613 | + | |
| 614 | + | |
| 615 | + | |
| 616 | + | |
579 | 617 | | |
580 | 618 | | |
581 | 619 | | |
| |||
599 | 637 | | |
600 | 638 | | |
601 | 639 | | |
| 640 | + | |
| 641 | + | |
| 642 | + | |
| 643 | + | |
602 | 644 | | |
603 | 645 | | |
604 | 646 | | |
| |||
628 | 670 | | |
629 | 671 | | |
630 | 672 | | |
| 673 | + | |
631 | 674 | | |
632 | 675 | | |
633 | 676 | | |
| |||
637 | 680 | | |
638 | 681 | | |
639 | 682 | | |
| 683 | + | |
| 684 | + | |
| 685 | + | |
| 686 | + | |
| 687 | + | |
| 688 | + | |
| 689 | + | |
| 690 | + | |
| 691 | + | |
| 692 | + | |
| 693 | + | |
| 694 | + | |
| 695 | + | |
| 696 | + | |
| 697 | + | |
| 698 | + | |
| 699 | + | |
| 700 | + | |
| 701 | + | |
| 702 | + | |
| 703 | + | |
| 704 | + | |
| 705 | + | |
| 706 | + | |
| 707 | + | |
| 708 | + | |
| 709 | + | |
| 710 | + | |
640 | 711 | | |
641 | 712 | | |
642 | 713 | | |
| |||
Lines changed: 120 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
| 21 | + | |
21 | 22 | | |
22 | 23 | | |
23 | 24 | | |
| |||
647 | 648 | | |
648 | 649 | | |
649 | 650 | | |
| 651 | + | |
| 652 | + | |
| 653 | + | |
| 654 | + | |
| 655 | + | |
| 656 | + | |
| 657 | + | |
| 658 | + | |
| 659 | + | |
| 660 | + | |
| 661 | + | |
| 662 | + | |
| 663 | + | |
| 664 | + | |
| 665 | + | |
| 666 | + | |
| 667 | + | |
| 668 | + | |
| 669 | + | |
| 670 | + | |
| 671 | + | |
| 672 | + | |
| 673 | + | |
| 674 | + | |
| 675 | + | |
| 676 | + | |
| 677 | + | |
| 678 | + | |
| 679 | + | |
| 680 | + | |
| 681 | + | |
| 682 | + | |
| 683 | + | |
| 684 | + | |
| 685 | + | |
| 686 | + | |
| 687 | + | |
| 688 | + | |
| 689 | + | |
| 690 | + | |
| 691 | + | |
| 692 | + | |
| 693 | + | |
| 694 | + | |
| 695 | + | |
| 696 | + | |
| 697 | + | |
| 698 | + | |
| 699 | + | |
| 700 | + | |
| 701 | + | |
| 702 | + | |
| 703 | + | |
| 704 | + | |
| 705 | + | |
| 706 | + | |
| 707 | + | |
| 708 | + | |
| 709 | + | |
| 710 | + | |
| 711 | + | |
| 712 | + | |
| 713 | + | |
| 714 | + | |
| 715 | + | |
| 716 | + | |
| 717 | + | |
| 718 | + | |
| 719 | + | |
| 720 | + | |
| 721 | + | |
| 722 | + | |
| 723 | + | |
| 724 | + | |
| 725 | + | |
| 726 | + | |
| 727 | + | |
| 728 | + | |
| 729 | + | |
| 730 | + | |
| 731 | + | |
| 732 | + | |
| 733 | + | |
| 734 | + | |
| 735 | + | |
| 736 | + | |
| 737 | + | |
| 738 | + | |
| 739 | + | |
| 740 | + | |
| 741 | + | |
| 742 | + | |
| 743 | + | |
| 744 | + | |
| 745 | + | |
| 746 | + | |
| 747 | + | |
| 748 | + | |
| 749 | + | |
| 750 | + | |
| 751 | + | |
| 752 | + | |
| 753 | + | |
| 754 | + | |
| 755 | + | |
| 756 | + | |
| 757 | + | |
| 758 | + | |
| 759 | + | |
| 760 | + | |
| 761 | + | |
| 762 | + | |
| 763 | + | |
| 764 | + | |
| 765 | + | |
| 766 | + | |
| 767 | + | |
| 768 | + | |
| 769 | + | |
650 | 770 | | |
651 | 771 | | |
652 | 772 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
496 | 496 | | |
497 | 497 | | |
498 | 498 | | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
499 | 511 | | |
500 | 512 | | |
501 | 513 | | |
| |||
0 commit comments