0

I have a .m3u8 file to stream using Videogular 2 and I want to have a start time that is a few seconds into the video, it works fine with mp4 but not with hls when I use vgAPI seekTime() function

VIEW

<vg-player *ngIf="videoreveal && gameOpen != 'open'" (onPlayerReady)="onPlayerReady($event)">
    <video #myMedia
           [vgHls]="videoreveal"
           id="singleVideo"
           type="video/mp4"
           crossorigin
           poster="assets/imgs/bg_live.png" 
           playsinline 
           webkit-playsinline="webkit-playsinline" 
          autoplay>
    </video>
</vg-player>

CONTROLLER

  onPlayerReady(api: VgAPI) {

    let d = new Date();
    let mins = d.getMinutes();
    let secs = d.getSeconds();

    let startSecs = parseInt(this.startMin) * 60;
    let currentSeconds = secs + (mins * 60);
    let timeDiff = currentSeconds - startSecs; 

    //console.log('time start seconds ' + startSecs);
    //console.log('time seconds ' + currentSeconds);
    //console.log('time delay ' + timeDiff);

    if( mins < this.endMins) 
    {

      api.seekTime(timeDiff);

    }

  }
Aleksey Solovey
  • 4,153
  • 3
  • 15
  • 34
condo1234
  • 3,285
  • 6
  • 25
  • 34

1 Answers1

0

HLS streams in Videogular 2 don't fire events to the regular VgAPI api object. Instead they are fired to the VgHLS object (because hls is a separate library to Videogular).

Unfortunately, VgHLS is not being exported at this point in time - the videogular2/streaming module is only exporting VgStreamingModule (compare this to the videogular2/core module that exports VgAPI). This means we cannot access it easily.

The only solution for now is to access the hls.js object and listen to the events as they are fired.

Hopefully in the future VgHLS will be exposed as part of the Videogular library, but for now I'd recommend creating an issue in the git repository or potentially creating a pull request of your own if you find a solution.

Source: comment by the creator of Videogular (April 19th 2018)