How to enable audio auto-play on iPhones and iPads?

Hello,


Does anyone know how to enable auto-play for audio on iPads and iPhones? So far I have only seen posts on how to enable auto-play for videos (on iPads & iPhones); how to enable auto-play for audio for Safari browser on Macbooks.


How about audio auto-play for iPhones and iPads? I really need some help here 🙏🏻



iPhone 13 Pro Max, iOS 16

Posted on May 17, 2023 02:21 AM

Reply
2 replies

Oct 11, 2023 09:18 PM in response to ASTRO24

I have a webRTC voice calling application using javascript.

Whenever it receives a stream , it will dynamically create a audio tag and add stream to its srcObject then play it.


While trying to play it, it throws following error

The request is not allowed by the user agent or the platform in the current context, possibly because the user denied permission


Following is the source code:


      const audioElement = document.createElement("audio");
      audioElement.srcObject = stream;
      audioElement.id = socketid;
      audioElement.key = socketid;
      audioElement.muted = false;
      audioElement.autoplay = true;
      audioElement.playsInline = true;


      // Append the audio element to the parent div
      allAudioStreamBlockRef.current.appendChild(audioElement);
      audioElement.play().catch((error) => {
        
          window.alert("Audio playback error: " + error.message);
                 
      });


Based on research, i found that it was because of auto-play blocking policy


So i have added a button and tried to play it again


audioElementsRef.current.forEach((audioElement) => {
        audioElement.muted = false;
        audioElement.play().catch((error) => {
         
          console.log(
            `[INFO][CLIENT] Again getting error while playing: ${error.message}`
          );
        });
      });


But still getting same error. it is not able to play the audio even after getting user interaction (play using a button click)



audio is playing in iPadOS v15.7.8 safari Also tested in iphone (IOS v16.1, v16.1.1) everything was working


Issue occurred only in iPadOS 16.2 safari browser only.

May 18, 2023 04:51 PM in response to Ivy Luo

Hi Ivy Luo,


Thanks for posting in Apple Support Communities.


We understand you want to enable audio only to autoplay on iOS devices. This can be dependent on the website's plug ins. The autoplay is up to the website developer to enable. For Macs, you can enable autoplay for videos and audio. There isn't a way to enable this only for audio. Most audio sites will have an app you can configure.


You can find some helpful details in Stop autoplay videos in Safari on Mac - Apple Support.


Regards.


This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

How to enable audio auto-play on iPhones and iPads?

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.