javascripthttp-live-streamingbitmovin-player

How to play HLS live-stream from the end with Bitmovin player


I want to play live streams from "live-edge" instead of playing from the start (first segment of manifest) with Bitmovin player.

With some HLS streams, the playback starts from the beginning of the live event. The user must manually click the "Live" button to jump to the current part of the stream. While this behavior is acceptable for VODs, it is not appropriate for live streams.

My config is as follow:

{key: '-', playback: {live: { edgeThreshold: 5 }, autoplay: true, muted: true}}

Also, with desktop browser element inject document.getElementById("#bmpui-id-185").click(); does work, but that's nasty and doesn't work on mobile.


Solution

  • None of the above proposals seemed to work but thanks for the well-written comment!

    After quite some while of trials, I finally found a working way to seek until the stream end. For some reason timeout is also necessary, probably should be ideally some play callback event. Player.seek() didn't seem to function at all with my test track.

    player = new bitmovin.player.Player(document.getElementById('player-container'), {playback: { live: { edgeThreshold: 5 }, autoplay: true, muted: true}});
    
    player.load(source).then(() => {
      if(player.isLive()){
        setTimeout(() => player.timeShift(Infinity), 10)
      }
    }).catch((error) => console.error('Error loading player:', error));