4

I am trying to get an event to fire when a movie finishes playing. The movie appears when a link is clicked and is in a dojo dialog. I am using the tag to play the movie and have attempted to use dojo connect to have an alert appear when the movie finishes playing by using the onEnded attribute. However nothing happens. Any ideas on what my problem is? Code is as follows:

dialog = new dijit.Dialog({
    content: "<embed id='video' src='http://www.tizag.com/files/html/htmlexample.mpeg' autostart='true' controller='false'/>"
});
dialog.show();
dojo.connect(dojo.byId("video"), "onEnded", function(e){alert(e);});
shortspider
  • 1,045
  • 15
  • 34

1 Answers1

0

Normally, existing DOM events are lowercased and dijit custom events are camelCased. Assuming I got my search right, the correct event to bind to is onended, without the uppercase "E":

Detect when an HTML5 video finishes

dojo.connect(dojo.byId("video"), "onended", function(e){alert(e);});
Community
  • 1
  • 1
hugomg
  • 68,213
  • 24
  • 160
  • 246
  • I tried the code you posted and it still isn't working. THe dialog appears, the video plays but when the video is over no alert appears. – shortspider Dec 07 '11 at 16:28
  • What happens if you don't use dojo.connect? `document.getElementById('video').onended = fucntion(){ alert('aaa')}` – hugomg Dec 07 '11 at 18:18
  • Unfortunately that also does not work. Could it be a scoping issue? Should I have the dojo.connect defined in the dialog content? Thanks for your help by the way. – shortspider Dec 07 '11 at 20:58
  • After further tests the above solon, not using dojo.connect, works if the video is not a url (i.e. is stored locally). That is good enough for me so I'm going to close this. Thank you so much for your help @missingno – shortspider Dec 08 '11 at 06:30