Royal Slider: Play video when clicking anywhere in the preview image

Here is the code I use to play a YouTube or Vimeo video in a Royal Slider gallery when a visitor clicks anywhere in the preview image, and not just when they click the Play button itself:

<script>
jQuery(document).ready(function($) {
    $('.royalSlider').each(function() {
      var slider = $(this);
      $('.rsContainer').click(function() {
        slider.royalSlider('playVideo');
      });
    });
});
</script>