最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - sanitizing unsafe URL when local video played in angular with html 5 video tag - Stack Overflow

programmeradmin2浏览0评论

When the local video is played in html5 video tag.It throws warning as unsafe URL and video content is not playing.

sanitizing the URL withdomSanitizer.bypassSecurityTrustResourceUrl(url)in angular still has the same issue

Added the stackblitz ponent.ts

Please help me out..

When the local video is played in html5 video tag.It throws warning as unsafe URL and video content is not playing.

sanitizing the URL withdomSanitizer.bypassSecurityTrustResourceUrl(url)in angular still has the same issue

Added the stackblitz https://stackblitz./edit/angular-uodypm?file=app%2Fapp.ponent.ts

Please help me out..

Share Improve this question edited Apr 25, 2018 at 7:44 Vikas 12k7 gold badges48 silver badges71 bronze badges asked Apr 25, 2018 at 7:11 Harish98Harish98 4853 gold badges7 silver badges18 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 6

use binding in video source element

<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./edit/angular-h5zawg?file=app/app.ponent.html

I have also faced similar kind of issue for video and here's a way how I resolved it. You can set SRC in HTML like mentioned below to resolve unsafe data issue for image/video.

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

Bind src like this: [src]="sanitizer.bypassSecurityTrustResourceUrl(src)"

发布评论

评论列表(0)

  1. 暂无评论