Adding a timeUpdate event - an example

    Follow

    This example shows how to embed a player and use the timeUpdate event to stop the player if more than 30% of the video is played or if the user seeks beyond that point. Of course, since this limitation is completely handled by the user's browser, a technically competent user could disable this check.

     <div id = "player"></div>
     <script type="text/javascript">
     picsearch_ajax_auth = 'iPvClRxkn6vBNijOf7r_DUQHhzoza63ELH2gS2ci0EZIzIQenBBhzg';
     var mediaid = 'tPVdD20hGOvkpZQGg0bK2w';
     ps.getMediaDetails(mediaid, ['duration'], function(details) {
      ps.embed({mediaid: mediaid, containerid: 'player', width: 500}, function(embed) {
       embed.player.addEventListener('timeUpdate', function(time) {
        if (time > 0.3 * (details.duration / 1000)) {
         embed.player.stop();
         alert('Playing too much!');
        };
       });
      });
     });
     </script>
    Was this article helpful?
    0 out of 0 found this helpful

    Comments