phoboslab / jsmpeg

MPEG1 Video Decoder in JavaScript
MIT License
6.33k stars 1.43k forks source link

Audio on iPhone 8/X #234

Open buzeandrei opened 6 years ago

buzeandrei commented 6 years ago

Hello,

the audio doesn't seem to work on either iPhone 8 or X . Has anyone encountered this?

Thanks!

mralexgray commented 6 years ago

Audio not working on iPhone 7+, iOS v11.1.2, either.

janyo1201 commented 6 years ago

Hi all,I also meet this issue. iPhone X version is 11.4.1

8272 commented 6 years ago

Is there any solution to fix this issue? thx

mralexgray commented 6 years ago

It does work... sometimes. Somehow. I got it working one day.. and then changed something, and it stopped working. Seems to have something to do with the surrounding markup, or which event handlers you have floating around. I don’t know. :-(

worldflyingct commented 5 years ago

you need run a audio element by click or touchstart event firstly.

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
  })
})
ghost commented 5 years ago

Before playing audio, you should break the restriction in modern mobile web browser first!

How to break it? Interact with the browser via vaild user interactions described at here.

An example:

document.body.addEventListener('touchend', () => {
  // play JSMpeg
})