Created
August 11, 2010 13:37
-
-
Save bergman/518984 to your computer and use it in GitHub Desktop.
Manual binding of events for html5 video in GWT
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MyVideoPlayer { | |
private void onPlay() { | |
// do something | |
} | |
private native void bindEvents() /*-{ | |
var instance = this; | |
var v = this.@MyVideoPlayer::getVideoElement()(); | |
v.addEventListener("click", function() { instance.@MyVideoPlayer::onClick()(); }); | |
v.addEventListener("touchstart", function() { instance.@MyVideoPlayer::onClick()(); }); | |
v.addEventListener("ended", function() { instance.@MyVideoPlayer::onEnded()(); }); | |
v.addEventListener("play", function() { instance.@MyVideoPlayer::onPlay()(); }); | |
v.addEventListener("pause", function() { instance.@MyVideoPlayer::onPause()(); }); | |
v.addEventListener("timeupdate", function() { instance.@MyVideoPlayer::onTimeupdate()(); }); | |
v.addEventListener("loadedmetadata", function() { instance.@MyVideoPlayer::onLoadedmetadata()(); }); | |
v.addEventListener("durationchange", function() { instance.@MyVideoPlayer::onDurationChange()(); }); | |
}-*/; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment