0

I am trying to Autoplay an mp3 file using html5 on ipad but its not working

Here is my code

<audio src="1.mp3" autoplay="" controls="" onended="this.play()"></audio>
user580950
  • 3,558
  • 12
  • 49
  • 94

3 Answers3

1

The iPad does not support autoplaying of video and audio files. This is a design decision.

Ian Devlin
  • 18,534
  • 6
  • 55
  • 73
  • Well it's disabled for good reason, but if you insist, read this: http://stackoverflow.com/questions/3009888/autoplay-audio-files-on-an-ipad-with-html5 – Ian Devlin Aug 30 '11 at 10:24
0

I found a way to auto-play video. I think is working on audio, also.

It works if you append/empty every time the video element from the div.

function addListeners()
{
    // loop for each list item
    $('#mscroll li').each(function looping(index)
    {
        // onclick...
        $(this).click(function onItemClick()
        {
            // empty left column and description
            $("#divplayer").empty();
            // append video tag
            $("#divplayer").append('<video width="'+video_width+'" height="'+video_height+'" controls="controls"><source src="'+videos_array[index].mp4+'" autoplay/></video>');
            $('video').get(0).play();
        });
    });
}

I have tested this on my Ipad, iOS 5.1.1

Adrian
  • 671
  • 4
  • 17
  • 37
0

Here is a pretty detailed overview of mobile audio and tricks to make it work, created in 2013, so quite recent: http://pupunzi.open-lab.com/2013/03/13/making-html5-audio-actually-work-on-mobile/

Good luck!