I would like to trigger a simple event when my video is finished. I've placed this directly bellow my video tag.
<script type="text/javascript">
var myPlayer = videojs("session_video");
videojs("session_video").ready(function(){
this.addEvent("ended", function(){
alert('Here I am');
});
});
</script>
However I get: TypeError: this.addEvent is not a function and I can't find why.
You can see it live here: 78.47.121.50 (stackoverflow won't allow to make that a link) enter code 01-01-01-2012 to bring up the video.
Any insight is much apricaited!
Kind regards, Jason.
"addEvent" and "removeEvent" were replaced by "on" and "off"
try:
this.on("ended", function(){
For those who still have problems with ended events in some browsers you can resort to this fix:
player.ready(function() {
var myPlayer = this;
playerInstance.on("timeupdate", function(event) { //chrome fix
if (event.currentTarget.currentTime == event.currentTarget.duration) {
console.log('video ended');
}
});
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With