jwplayerjwplayer6

jwplayer: how to disable seek on not viewed part of video?


I am using jwplayer 6.8.4616. I don't want users to seek to the part of video which he have not already watched, allowing to seek the part which have already watched, but unable to find good solution.

I have tried JWPlayer Prevent SKipping forward unless already watched in google chrome 39.0.2171.71 + ubuntu 14.04. It does not work for me unless I set timeout value to atleast 1500ms in that solution, but if timeout is too long then it becomes visible.

if not through javascript, can it be done using custom skins or plugins. can it be done in some higher version of jwplayer if not in my versio?

EDIT: The above approach works for MP4 video, but not for HLS streams.


Solution

  • Try this more simple embed, for starters:

    <!DOCTYPE html>
    <html>
    <head>
      <title>Disable Seek</title>
        <script type='text/javascript' src='https://cdn.jwplayer.com/libraries/Jq6HIbgz.js'></script>
      <style type="text/css">
        body { margin: 0; padding: 0 }
      </style>
    </head>
    <body>
    <div id="thePlayer"></div>
    <script type="text/javascript">
    jwplayer("thePlayer").setup({
        image: "http://content.bitsontherun.com/thumbs/w5co0c24-480.jpg",
        file: "http://content.bitsontherun.com/videos/w5co0c24-hV866gPy.mp4"
    });
    var maxPlayPosition = 0;
    var seeking = false;
    jwplayer().on("time", function (event) {
        if (!seeking) maxPlayPosition = Math.max(event.position, maxPlayPosition)
    }).on("playlistItem", function () {
        maxPlayPosition = 0
    }).on("seek", function (event) {
        if (!seeking) {
            if (event.offset > maxPlayPosition) {
                seeking = true;
                setTimeout(function () {
                    jwplayer().seek(maxPlayPosition)
                }, 100)
            }
        } else seeking = false
    });
    </script>
    </body>
    </html>