the load event is triggered on the mediaElement. just move up the line "mediaElement.onload" that you have in the image case