简体   繁体   English

使用JavaScript检测iOS移动设备比自动播放音频

[英]Detect iOS Mobile Device with JavaScript than auto play audio

I would like to Detect iOS Mobile Device or Mobile safari with JavaScript than auto play audio with JavaScript. 我想用JavaScript检测iOS移动设备或移动Safari,而不是用JavaScript自动播放音频。 I have tried versions of this code but its just not playing, any thought on why this is not playing. 我已经尝试过此代码的版本,但它只是无法播放,因此对为什么它无法播放有任何想法。 Thank you 谢谢

function untitledFunction3 (hypeDocument element, event) {

if( isMobile.iOS() );
var audio = new Audio("http://polyflor.squarespace.com/storage/vo/low-res-mp3/PolyFlor_1_intro_timed_sized.mp3");
audio.play();
}

The Audio html5 API is not supported in mobile webkit yet. 移动Webkit尚不支持Audio html5 API。

http://caniuse.com/audio-api http://caniuse.com/audio-api

Try using something like soundplayer2, it works in mobile safari, is fairly lightweight, and has fallbacks. 尝试使用诸如soundplayer2之类的东西,它可以在移动safari中使用,非常轻巧,并且具有备用功能。

http://www.schillmania.com/projects/soundmanager2/ http://www.schillmania.com/projects/soundmanager2/

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

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