Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unlocking audio on iOS does not work #151

Open
huyngovan opened this issue Mar 31, 2017 · 3 comments
Open

Unlocking audio on iOS does not work #151

huyngovan opened this issue Mar 31, 2017 · 3 comments

Comments

@huyngovan
Copy link

Hi ...
I tried unlocking the sound under the command line below but could not unlock audio on iOS, can only unlock sound on PC and Android browser.

document.body.addEventListener('touchstart', function(){
	player.audioOut.unlock(function(){
		alert('unlocked!');
	});
});

Anyone plz tell me unlock sound on iOS?

Thank you for your help

@ps91
Copy link

ps91 commented May 17, 2017

I'm having the same problem. Did you find a solution?

@ps91
Copy link

ps91 commented May 17, 2017

#162 This worked for me.

@worldflyingct
Copy link

I find that I need to trigger a audio element work firstly, this is my solution:

document.addEventListener('touchstart', function () {
  // 手动启动audio,解除新的ios audio不能自动播放的问题
  var audio = document.createElement('audio')
  audio.autoplay = 'autoplay'
  audio.volume = 0
  audio.src = 't.aac'
  // 手动触发audiocontext,让其从suspended变为running模式
  _this.player.audioOut.unlock(function() {
    _this.unlockstate = true
  })
})

t.acc is a little audio file, just 1s, use to trigger audio element to work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants