简体   繁体   中英

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. 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.

http://caniuse.com/audio-api

Try using something like soundplayer2, it works in mobile safari, is fairly lightweight, and has fallbacks.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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