my target is to play audio file with quicktime plugin and listen for the audio end event and then update the audio object with another file to play and so on
here is the audio element (I am using primefaces4):
<h:panelGroup id="questionsAudioPG">
<object width="2" height="2" data="#{testBean.audioPath}" id="speechAudio"
name="speechAudio" >
<param name="CONTROLLER" value="false" />
<param name="AUTOPLAY" value="true" />
<param name="LOOP" value="false" />
<param name="POSTDOMEVENTS" value="true" />
<param name="ENABLEJAVASCRIPT" value="true" />
</object>
</h:panelGroup>
and here is my javascript code:
<h:outputScript type="text/javascript">
$(document).ready(function(){
RegisterListener('qt_ended', 'speechAudio', 'speechAudio_embed', audioEndedEventFired);
});
function audioEndedEventFired() {
audioEnded();
}
function myAddListener(obj, evt, handler, captures) {
if (document.addEventListener)
obj.addEventListener(evt, handler, captures);
else
// IE
obj.attachEvent('on' + evt, handler);
}
function RegisterListener(eventName, objID, embedID, listenerFcn) {
var obj = document.getElementById(objID);
if (!obj)
obj = document.getElementById(embedID);
if (obj)
myAddListener(obj, eventName, listenerFcn, false);
}
</h:outputScript>
what is happening now is that my listener is working properly at the first time, but after my handler function updates the page by ajax the event is never fired again !!
I guess that this is happening because the DOM is changed and I need to re register the event listener again after each ajax update to the audio element.
BTW: the qt event is fired on chrome only and not fired in firefox.
any help is appreciated.