...

View Full Version : JavaScript and iOS iPad



ericp
07-17-2012, 09:21 PM
Hi,
I am using a code that works fine with Chrome IE9, firefox, Safari but with Safari or Chrome on iOS no sound at all.
here is the code:
var html5_audiotypes={ //define list of audio file extensions and their associated audio types. Add to it if your specified audio file isn't on this list:
"mp3": "audio/mpeg",
"mp4": "audio/mp4",
"ogg": "audio/ogg",
"wav": "audio/wav"
}

function createsoundbite(sound){
var html5audio=document.createElement('audio')
if (html5audio.canPlayType){ //check support for HTML5 audio
for (var i=0; i<arguments.length; i++){
var sourceel=document.createElement('source')
sourceel.setAttribute('src', arguments[i])
if (arguments[i].match(/\.(\w+)$/i))
sourceel.setAttribute('type', html5_audiotypes[RegExp.$1])
html5audio.appendChild(sourceel)
}
html5audio.load()
html5audio.playclip=function(){
html5audio.pause()
html5audio.currentTime=0
html5audio.play()
}
return html5audio
}
else{
return {playclip:function(){throw new Error("Your browser doesn't support HTML5 audio unfortunately")}}
}
}

var clicksound=createsoundbite("sound/1.ogg", "sound/1.mp3") ...

then the html is an on click text,

any idea?
thanks

ericp
07-17-2012, 10:42 PM
well, the html script was "playclip", this fonction works but not on ipad, just replace it by "play"!



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum