2017-09-21 44 views

回答

2

我必須將一些視頻上傳到Angular應用程序(MEAN)中是否有標準方法?

沒有「特殊絕密中央情報局法」這樣做。

您只需將視頻文件存儲在特定的目錄中或使用雲存儲選項,如AWS S3Cloudinary

接下來,您將獲得指向視頻文件的鏈接並使用HTML5嵌入它。

<embed src="example.mpeg" autostart="false" height="30" width="144" /> 

此外,您還可以上傳至YouTube和嵌入視頻使用嵌入標籤

<iframe width="425" height="344" src="https://www.youtube.com/embed/F9Bo89m2f6g" frameborder="0" allowfullscreen></iframe> 

您可以瞭解更多here

角形支持,你可能需要做一些更多的事情,你必須先清理URL。

導入DomSanitizer使用它。

import { DomSanitizer } from '@angular/platform-browser'; 

獲取DomSanitizer並清理鏈接。

constructor(private sanitizer: DomSanitizer){ 
    let videoURL = "https://www.youtube.com/watch?v=1KT2asqA1J8"; 
    this.safeURL = this.sanitizer.bypassSecurityTrustResourceUrl(videoURL); 
} 

然後將值safeUrl綁定到組件文件中的iframe。

<iframe [src]='safeURL' frameborder="0" allowfullscreen></iframe> 
相關問題