Saturday, November 5, 2016

Bug in Audio addEndedHandler

If you want to listen for the end of an audio track, calling MediaBase.addEndedHandler won't work, as it is using BrowserEvents.ENDED which is set to "ended".

The correct event is actually "onended".  Ref:  http://www.w3schools.com/tags/av_event_ended.asp

So, here is a little JSNI function to do it:

public static native final void listenForEnd(AudioElement aud, Command onComplete) /*-{
   aud.onended = function() {
      onComplete.@com.google.gwt.user.client.Command::execute(*)();
   };
}-*/
;

Hope that helps someone.

Cheers.

--
You received this message because you are subscribed to the Google Groups "GWT Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at https://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment