Jwplayer 6 item search in playlist not working

We use an external scrubber (a user interface element that is not the default search string) to search (via jquery ui draggable), and it does not update jwplayer when it should be.

Summary of our code:

$('#scrubber').draggable({

    // ...

    stop: function (event, ui) {

        $('#scrubber').draggable('enable');

        var intSecFromEnd,
            intSeek,
            intTotalTime = 0,
            intScrubPosition = ui.position.left,
            intScrubTime = intScrubPosition;

        // Find which video in the playlist to use
        $.each(playlist, function (i, obj) {

            intTotalTime += parseInt(obj.duration);

            if (intTotalTime > (intScrubTime)) {

                intSecFromEnd = intTotalTime - parseInt(intScrubTime);
                intSeek = Math.floor((parseInt(obj.duration) - intSecFromEnd));

                jwplayer('videoPlayer').load(playlist);
                jwplayer('videoPlayer').playlistItem(i);
                jwplayer('videoPlayer').seek(intSeek);
                jwplayer('videoPlayer').pause();


                /*
                    Play the video for 1 second to refresh the video player, so it is correctly displaying the current point in the video
                    Does not work either
                */
                // setTimeout(function () {
                //     jwplayer('videoPlayer').pause();
                // }, 1000);

                return false;
            }
        });
    }
});

You will notice a key bit:

jwplayer('videoPlayer').load(playlist);
jwplayer('videoPlayer').playlistItem(i);
jwplayer('videoPlayer').seek(intSeek);
jwplayer('videoPlayer').pause();

When I put this in the console directly with an integer value, where it intSeekworks exactly as it should, so I am puzzled where this might be a disconnect.

(which only works one item in a playlist)

This only works with the first member of the playlist because the seek () function is considered to be an item 0in the playlist by default .

jwplayer('videoPlayer').load(playlist);
jwplayer('videoPlayer').seek(intSeek);
jwplayer('videoPlayer').pause();

, , jwplayer('videoPlayer').playlistItem(i) , , :

.

, , , .

  • .seek() onSeek() jwplayer.

  • , jwplayer onReady . jwplayer(strVideo).playlistItem(i).onReady({ console.log('ready'); });

+4
1

PlaylistItem (index).seek( ), . , , .

. , , , :

jwplayer().onPlaylistItem(<index_file>).seek(seconds);

, .

previuos, playListItem, , . ( html5, ).

<a onclick='var only_once =false;jwplayer().playlistItem(1);jwplayer().onPlay(function () {  
if (only_once == false) {
        only_once = true;
          jwplayer().seek(60);
    }
});' class="btn">HLS play 2nd file at 1 min</a>

Flash, html 5!

+1

All Articles