IOS 10移动音频.play()工作不稳定

IOS 10移动音频.play()工作不稳定,ios,html,audio,playback,Ios,Html,Audio,Playback,这是我的密码: $(document).on('click', 'div.play',function () { play = $(this); var stop = $('.stop'); contentId = play.attr('id'); nexttrack = nexttrackPlay(play); if(!play.parent().hasClass('stop')) { if(song ==undefined){ initAudio(play); } el

这是我的密码:

$(document).on('click', 'div.play',function () {
play = $(this);
var stop = $('.stop');
contentId = play.attr('id');
nexttrack = nexttrackPlay(play);

if(!play.parent().hasClass('stop')) {
  if(song ==undefined){
    initAudio(play);
  }
  else
  {
    song.src = play.attr('audiourl');
    song.load();
  }

  playerInit(play);
  stop.each(function () {
    $(this).removeClass('stop');
  });

  playAudio();
}
else{
  if(song.paused){
    playAudio();
  }
  else{
    stopAudio();
  }
}


 });

function initAudio(elem) {
var url = elem.attr('audiourl');
song = document.getElementsByTagName('audio')[0];
console.log(song);
song.src = url;
song.preload = 'metadata';
song.load();
    song.addEventListener('play', function () {
  $('.play-play').addClass('stop');
  play.parent().addClass('stop');
  play.removeClass('pause');
  $('.button-play').addClass('stop');
      song.removeEventListener('play',function(){  });
},false);

song.addEventListener('pause', function () {
  play.addClass('pause');
  $('.play-play').removeClass('stop');
  $('.button-play').removeClass('stop');
  song.removeEventListener('play',function(){  });
},false);


}
  function playAudio() {
    song.load();
  song.play();
  }
  function stopAudio() {
    song.pause();
  }

在安卓和台式机上工作正常,但在IOS上,首先单击“不工作”,然后单击另一首歌曲,然后再次开始播放。

我发现了问题和解决方案)
所有的东西都在标题中,我发送了内容类型为:application/octet stream的标题,这对于IOS来说是个问题,然后我将其更改为audio/mpeg并开始加载音频。

我们需要更多的内容