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.
Try using something like soundplayer2, it works in mobile safari, is fairly lightweight, and has fallbacks.
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.