Videogular 2 seekTime函数不适用于HLS流

时间:2018-09-11 13:01:36

标签: angular videogular

我有一个要使用Videogular 2播放的.m3u8文件,并且我希望视频的开始时间只有几秒钟,当我使用vgAPI seekTime()函数时,它可以在mp4上正常运行,但不能与hls一起运行

查看

<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);

    }

  }

1 个答案:

答案 0 :(得分:0)

Videogular 2中的HLS流不会将事件触发到常规VgAPI api对象。而是将它们触发到VgHLS对象(因为hls是Videogular的独立库)。

不幸的是,此时尚未导出VgHLS-videogular2 / streaming模块仅导出VgStreamingModule(将其与导出VgAPI的videogular2 / core模块进行比较)。这意味着我们无法轻松访问它。

目前唯一的解决方案是访问hls.js对象并在事件触发时监听事件。

希望将来VgHLS将作为Videogular库的一部分公开,但是现在,我建议使用creating an issue in the git repository或在您找到解决方案的情况下创建自己的请求请求。

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