Add "pause on detach" property support to the Audio component
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 1.8k
- Forks
- 717
- Avg merge
- 2d 6h
- Merged PRs (30d)
- 3
Description
Originally by mpilone
After researching a customer bug I found that browsers implement the removal/detach of the audio tag differently when audio playback has not yet started but the tag is set to autoplay. There appears to be some ambiguity in the specification as to what should happen with audio playback when the audio tag is removed from the DOM while still loading audio. For example, there is a Firefox bug thread about the issue here https://bugzilla.mozilla.org/show_bug.cgi?id=594748
While Vaadin can't completely hide the behavior of the different browsers, it would be useful to have a property on the Audio component such as "pauseOnDetach" that would instruct the client side connector to pause the Audio component when it is removed from the DOM which would prevent playback even if the audio was still loading at the time of detach.
I attempted to implement this server side first, but that didn't work because when the detach event is processed on the server side no changes to the component take affect because the client side connector has already been removed. I was then forced to extend the client side Audio component to add a listener and implement my own pause. I'll attach my code but it would be nice to have this as a standard feature of the component.
This issue can occur when the audio tag is, for example, in a Vaadin Window and the user closes the Window without pausing audio playback and the audio is still loading from the server. Depending on the browser's interpretation of the HTML5 specification, the audio may start to playback with no way for the user to stop it. In my specific case I have to do audio transcoding if I don't have a cached version of the audio format which causes a 5 to 10 second delay for the user. If the user closes the Vaadin Window with the Audio component in it, the audio may still play back once the transcoding is done.
Imported from https://dev.vaadin.com/ issue #14650
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by locating the Audio component and its client-side connector, then review how detach events are handled while autoplay audio is still loading. Reproduce the Window-close scenario described in the issue; done means a pauseOnDetach property prevents playback after the component is detached, including during delayed audio loading.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- html, java
- Domain
- frontend, web-dev
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100