I am facing an issue while working with videos in Angular. I am fetching the video URLs from an API to embed them in my application using the
sanitazer.bypassSecurityTrustResourceUrl
function provided by Angular. The videos are being displayed correctly without any issues. However, whenever I click on something, press a key, or scroll the window, the browser sends a request to the URL of the video. This results in the video being reloaded every time I trigger any event such as scrolling or clicking.
HTML OF THE EMBEDDED VIDEO
<iframe width="100%" height="315" *ngIf="block.blockType === 'Clip'"
[src]="sanitazeURL(block.blockElement.url)"></iframe>
Typescript
public sanitazeURL(url: string) {
const videoUrl = `https://${url}`;
return this.sanitazer.bypassSecurityTrustResourceUrl(videoUrl);
}