微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

Angular 8 - 视频无法在灯箱中播放

如何解决Angular 8 - 视频无法在灯箱中播放

我可以在灯箱中显示图像

但是当尝试在 ngx-lighBox 中播放视频时。但它不起作用。也没有收到任何错误

我使用了以下链接中的参考

https://therichpost.com/angular-9-angular-ngx-lightbox/

代码HTML:

<div *ngFor="let image of _albums; let i=index">
  <img [src]="image.thumb" (click)="open(i)" />
</div>

 typescript:
 _albums = [];
  constructor(private _lightBox: LightBox) {
    for (let i = 1; i <= 4; i++) {
      const src = 'https://themyth92.com/project/ngx-lightBox/demo/img/image' + i + '.jpg';
      const caption = 'Image ' + i + ' caption here';
      const thumb = 'https://themyth92.com/project/ngx-lightBox/demo/img/image' + i + '-thumb.jpg';
      const album = {
         src: src,caption: caption,thumb: thumb
      };
 
      this._albums.push(album);
    }
  }
 
  open(index: number): void {
    // open lightBox
    this._lightBox.open(this._albums,index);
  }

解决方法

请试试这个片段

this.lightbox.opened.subscribe(res => {
  setTimeout(() => {
    const video: HTMLMediaElement = document.querySelector("#lightbox-video-gallery .g-active-item video");
    if(video) {
      video.play();
    }
  });
});

您还可以查看此库 https://www.positronx.io/angular-video-player-using-ngx-videogular-with-customized-controls-example/

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。