...

View Full Version : Click sound effect OK for Firefox but not IE



mamboze
01-02-2012, 07:20 AM
Hi
this is my first forum post. I'm developing a website for use in Thai schools in which clicking on link (at the beginning of a line of English text) starts a sound file (ogg or mp3).

I've been using the Mouseover/Click sound effect script from by JavaScript Kit (www.javascriptkit.com). It works as designed in Firefox and Opera but doesn't in IE8. The script relies on HTML5 functionality so it should be compatible with IE8 (so I understand).

I'm using Ubuntu 10.04 with Windows XP SP3 as the guest OS on VirtualBox. it seems to be a problem specific to IE8 (perhaps, not too surprising!) since the script works OK for Firefox and Opera.

Here is the script


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")}}
}
}
//Initialize two sound clips with 1 fallback file each:
var a=createsoundbite("chot_pic01.ogg", "chot_pic01.mp3")
var b=createsoundbite("chot_pic02.ogg", "chot_pic02.mp3")
.............................
.............................


I only know a little Javascript at present, so I would be thankful of any help

mamboze
01-02-2012, 08:20 AM
I suppose I should mention that the audio files triggered by the onclick events contain spoken English corresponding to the text on the screen.

devnull69
01-02-2012, 09:29 AM
HTML5 <audio> tag is only supported for IE>8

mamboze
01-02-2012, 09:53 AM
Thanks, I'll upgrade IE.

mamboze
01-13-2012, 06:09 AM
Unfortunately, there are a massive number of IE<9 users out there.

I've looked around for tutorials or examples of onclick actuating audio files relevant to pre-html5. I'm not talking about a single button or link controlling a single file. The functionality I'm looking for as I mentioned is for multiple audio files to be actuated by individual links specific to each file.

Any general pointers as to how I might approach this would be very much appreciated. I have a background in C programming (not extensive but enough to orient me to Javascript) so I'm not exactly starting from square one.

TIA



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum