Forum Moderators: open

Message Too Old, No Replies

accessing when an audio clip is loaded

         

ctoz

6:41 am on Jul 8, 2014 (gmt 0)

10+ Year Member



Hi,

I'm using html4 to load an audio clip, and I want to access the event which is when the clip has loaded.

Turns out it's not "onload", because the <object> tag doesn't support "onload". You can blur() it and onclick it, but not "onload".

I've done some reading on <audio> in html5, and it looks still to be a bit of a can of worms amongst the browsers. Hence html4.

Any ideas?

<object onfocus="blur()" onclick="$('#instructions').hide();" classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" codebase="http://www.apple.com/qtactivex/qtplugin.cab" 
width="500" height="24" name="src" value="my.mp3" />
<param name="controller" value="true" />
<param name="autoplay" value="false" />
<!--[if !IE]>-->
<object onfocus="blur()" onclick="$('#instructions').hide();" type="audio/mpeg" data="my.mp3" width="500" height="24" />
<param name="autoplay" value="false" />
<param name="controller" value="true" />
</object>
<!--<![endif]-->
</object>

Cheers.

penders

9:55 pm on Jul 9, 2014 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I've done some reading on <audio> in html5, and it looks still to be a bit of a can of worms amongst the browsers. Hence html4.


Bit of an aside... but which browsers are you targeting? It's just that I'm not convinced your "HTML4" method will have better browser support. The problem before HTML5 is that audio support is dependent on external plugins, which by its very nature causes compatibility issues.

I've just tried your code in a few modern browsers on a Windows 7 machine... Chrome 35 appears to internally convert it to an HTML5 <video> element (yes, video, not audio?) and it plays OK. Firefox 30 appears to do something similar, in that it looks and behaves like the browsers HTML5 <audio> element (although the Object Inspector still states that it's an <object>) and it plays OK. However, IE 11, Opera 22 and Safari 5.1.7 all fail and complain about a "Missing Plug-in".

ctoz

10:55 pm on Jul 9, 2014 (gmt 0)

10+ Year Member



Thanks for that!

Back to the drawing board...

ctoz

8:27 am on Jul 10, 2014 (gmt 0)

10+ Year Member



This'll have to do:

<audio preload="auto" autoplay="autoplay" oncanplaythrough="myfunction();">
<source src="my.mp3" />
<source src="nmy.ogg" />
your current browser does not support the new audio standard: upgrade if you can.
</audio>