简体   繁体   English

HTML5音频标签JS touchstart事件在iPad上有效,在iPhone上无效

[英]HTML5 Audio Tag JS touchstart event working on iPad, not on iPhone

I have been working on making a wonderful site to play the GoT shame sound when a shame event is published in particle's SSE queue. 当在粒子的SSE队列中发布耻辱事件时,我一直在努力制作一个出色的网站来播放GoT耻辱声音。 Currently I have this working great on every device (iPad/Android/Desktop/etc) except for the iPhone. 目前,我可以在除iPhone之外的所有设备(iPad / Android /台式机等)上正常工作。

For mobile devices I am using the ontouchstart event to play/pause the audio file so that I can later initiate the JS play method when the shame SSE is seen. 对于移动设备,我正在使用ontouchstart事件来播放/暂停音频文件,以便稍后看到ontouchstart的SSE时可以启动JS播放方法。 When I add in the controls option the sound can be played by pressing play on the phone. 当我添加控件选项时,可以通过在手机上按播放来播放声音。 Even after that it is unable to be triggered via JS. 即使这样,它也无法通过JS触发。 Any help would be appreciated. 任何帮助,将不胜感激。 See code below 见下面的代码

Code: https://gist.github.com/nctiggy/17e87e68dedf8c4c4530 代码: https//gist.github.com/nctiggy/17e87e68dedf8c4c4530

Deployed to site: http://cersei.cfapps.io 部署到站点: http : //cersei.cfapps.io

Answered my own problem: 回答了我自己的问题:

Needed to run the load() method before the initial play/pause at the ontouchstart event. 需要在ontouchstart事件的初始播放/暂停之前运行load()方法。

Here is the working code: https://gist.github.com/nctiggy/67edb2df65b10ea28a58 这是工作代码: https : //gist.github.com/nctiggy/67edb2df65b10ea28a58

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM