Reputation: 1416
I want to play a HLS stream using jwplayer6 with ability to setup offset. My code looks like:
plist = [
{
file: '/uploads/index.m3u8',
main: true
}
];
jwplayer("fftv_player").setup({
playlist: plist,
height: 312,
width: 554,
primary: 'flash',
autostart: true
});
jwplayer("fftv_player").onPlaylistItem(function (obj) {
if (jwplayer("fftv_player").getPlaylistItem().main){
jwplayer("fftv_player").seek(20);
}
});
The problem that my item always starts playing from beggining. If I in console type: jwplayer("fftv_player").seek(20)
item starts playing from 20 second. Why that can be?
Upvotes: 1
Views: 1369
Reputation: 1148
we're trying onPlaylistItem(index).seek(seconds) but this doesn't works. This work only on active playlistitem and -of course- only about first file.
We're trying to use a pre-loaded playlist with seek button for every item of playlist. We use a playlist with more files and the user can go to a specific file and second clicking a button that call:
jwplayer().onPlaylistItem(<index_file>).seek(seconds);
This jump to the seconds but not to the correct playlist item.
With a previuos test using "playListItem" player jump to the correct file but start from beginning and not seek to seconds. (but work only in html5 mode and not with flash).
Now we've tested this code
<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>
but this solution works only in Flash mode and iOS, doesn't work in Safari (html 5 mode) and with Android > 4.1 (with androidhls option).
Upvotes: 1