当使用html 5视频标记以角度播放本地视频时,清理不安全的URL

时间:2018-04-25 07:11:20

标签: javascript angular

当本地视频以html5视频标签播放时,由于不安全的网址和视频内容无法播放,因此会发出警告。

使用角度domSanitizer.bypassSecurityTrustResourceUrl(url)清理网址仍然存在同样的问题

enter image description here

添加了stackblitz https://stackblitz.com/edit/angular-uodypm?file=app%2Fapp.component.ts

请帮帮我..

1 个答案:

答案 0 :(得分:5)

在视频源元素中使用绑定

<video *ngIf="playerSrc" width="100%" autoplay="autoplay" controls style="margin-top: 50px; margin-bottom: 20px;">
  <source [src]="playerSrc" type="video/mp4">
    </video>

stackblitz https://stackblitz.com/edit/angular-h5zawg?file=app/app.component.html