plyr.js add live button same as YouTube live stream [skip ahead live broadcast]

548 views Asked by At

I am using plyr.js, using this player iframe I am loading a youtube live stream video. I need to show the Live button on the player.

if a user is not watching the current live minutes, show this button and click it go current live stream point. same as in youtube player Live button.

Please help me.

1

There are 1 answers

0
mattaco On

I have been trying to find a solution for this as well and after asking ChatGPT for help and nothing it gave me really worked I played with a lot of different options and here is what I came up with that I think is working for me:

function resumeVideos() {
    player2.playVideo();
    var currentTime = player1.getCurrentTime();
    var targetTime = currentTime + 6000000;
    player1.seekTo(targetTime, true);
    player1.playVideo();

I tried many other things before this but this is what has been working consistently. I add the 6 million seconds (~1,700 hours) because when I look at the output of getCurrentTime anywhere on the seek bar (which seems to only go back ~12 hours) of this live video it is over 43 million seconds or ~12,120 hours (which must be the uptime of the stream?) so I add 6mil seconds to whatever the current time is and it should always be more than enough which takes you to the current live point. (video I've been testing with: https://www.youtube.com/embed/jfKfPfyJRdk)

hope this works for you or at least helps you get in the right direction.

(edit: pasted the wrong code, sorry)