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

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

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

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744616040a4584060.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信