| OLD | NEW |
| 1 # Audio Focus Handling | 1 # Audio Focus Handling |
| 2 | 2 |
| 3 A MediaSession collects all audio-producing objects in one tab. It is usually | 3 A MediaSession collects all audio-producing objects in one tab. It is usually |
| 4 unpleasant when multiple MediaSessions play sound at the same time. Audio focus | 4 unpleasant when multiple MediaSessions play sound at the same time. Audio focus |
| 5 handling manages the MediaSessions and mixes them in proper ways. This is part | 5 handling manages the MediaSessions and mixes them in proper ways. This is part |
| 6 of the default media session on desktop project. | 6 of the default media session on desktop project. |
| 7 | 7 |
| 8 [TOC] | 8 [TOC] |
| 9 | 9 |
| 10 ## Processing model | 10 ## Processing model |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 | 66 |
| 67 * Remove it from the audio focus stack if it's already there, and place it at | 67 * Remove it from the audio focus stack if it's already there, and place it at |
| 68 the top of audio focus stack, grant focus to the session and let it play. | 68 the top of audio focus stack, grant focus to the session and let it play. |
| 69 * If the session is persistent, suspend all the other sessions on the stack. | 69 * If the session is persistent, suspend all the other sessions on the stack. |
| 70 * If the session is transient, we should duck any active persistent audio | 70 * If the session is transient, we should duck any active persistent audio |
| 71 focus entry if present: | 71 focus entry if present: |
| 72 | 72 |
| 73 * If the next top entry is transient, do nothing, since if there is any | 73 * If the next top entry is transient, do nothing, since if there is any |
| 74 persistent session that is active, it is already ducking. | 74 persistent session that is active, it is already ducking. |
| 75 * If the next top entry is persistent, let the next top entry start ducking, | 75 * If the next top entry is persistent, let the next top entry start ducking, |
| 76 since it is the only active persisten session. | 76 since it is the only active persistent session. |
| 77 | 77 |
| 78 * When a `MediaSession` abandons audio focus: | 78 * When a `MediaSession` abandons audio focus: |
| 79 | 79 |
| 80 * If the session is not on the top, just remove it from the stack. | 80 * If the session is not on the top, just remove it from the stack. |
| 81 * If the session is on the top, remove it from the stack. | 81 * If the session is on the top, remove it from the stack. |
| 82 | 82 |
| 83 * If the stack becomes empty, do nothing. | 83 * If the stack becomes empty, do nothing. |
| 84 * If the next top session is transient, do nothing. | 84 * If the next top session is transient, do nothing. |
| 85 * If the next top session is persistent, stop ducking it. | 85 * If the next top session is persistent, stop ducking it. |
| 86 | 86 |
| 87 ### Handling Pepper | 87 ### Handling Pepper |
| 88 | 88 |
| 89 Pepper is different from media elements since it has a different model. Pepper | 89 Pepper is different from media elements since it has a different model. Pepper |
| 90 cannot be paused, but its volume can be changed. When considering Pepper, the | 90 cannot be paused, but its volume can be changed. When considering Pepper, the |
| 91 above algorithm must be modified. | 91 above algorithm must be modified. |
| 92 | 92 |
| 93 When Pepper joins `MediaSession`, it should request persistent focus type. When | 93 When Pepper joins `MediaSession`, it should request persistent focus type. When |
| 94 AudioFocusManager wants to suspend a `MediaSession`, it must check whether the | 94 AudioFocusManager wants to suspend a `MediaSession`, it must check whether the |
| 95 session has Pepper instance, and if yes, it should duck the session instead. | 95 session has Pepper instance, and if yes, it should duck the session instead. |
| 96 | 96 |
| 97 Also, whenever a session abandons focus, and the next top session is INACTIVE, | 97 Also, whenever a session abandons focus, and the next top session is INACTIVE, |
| 98 `AudioFocusManager` should find the next session having Pepper and unduck it. | 98 `AudioFocusManager` should find the next session having Pepper and unduck it. |
| OLD | NEW |