no-autoplay-audio-matches.js 534 B

12345678910111213141516171819202122
  1. function noAutoplayAudioMatches(node) {
  2. /**
  3. * Ignore media nodes without `currenSrc`
  4. * Notes:
  5. * - https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/currentSrc
  6. * - https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/src
  7. */
  8. if (!node.currentSrc) {
  9. return false;
  10. }
  11. /**
  12. * Ignore media nodes which are `paused` or `muted`
  13. */
  14. if (node.hasAttribute('paused') || node.hasAttribute('muted')) {
  15. return false;
  16. }
  17. return true;
  18. }
  19. export default noAutoplayAudioMatches;