title: How to ask Audio Autoplay permission in the browser(safari) with javascript
body: <p>I am getting this error in Safari(MAC), </p>
  
  <p><a href="https://i.stack.imgur.com/qPWtS.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/qPWtS.png" alt="enter image description here"></a></p>
  
  <p>i am implementing a feature that triggers audio alert when a buyer sends a request to the seller. I am able to play muted audio but it show error when it is being played Unmuted.
  I want to ask is there any way we can ask users to allow audio play permissin as like we ask geolocation or camera/mic access permission with JavaScript. 
  Any help would be appreciated. </p>
  
  <p>This is my code:</p>
  
  <pre><code>window.MutedAudioPlayed = false;
          window.MyAudio = new Audio("https://XXXX.com/input_sound.mp3");
          window.MyAudio.preload = 'auto';
          window.MyAudio.muted = true;
          window.MyAudio.play().then(function (event) {
              window.MutedAudioPlayed = true;
              console.log('Audio MutedAudioPlayed: ', window.MutedAudioPlayed);
          }).catch(function (error) {
              window.MutedAudioPlayed = false;
              console.log('Audio Play Error: ', error.message);
          });
  
          window.MyAudio.muted = false; 
          window.MyAudio.play().then(function (event) {
              console.log("Audio Play: ", event);
          }).catch(function (error) {
              console.log('Audio Play Error: ', error.message);
          });
  </code></pre>