我正在尝试绑定来自API的视频中的网址,但我正在接受下面的错误,我尝试过DomSanitizer和其他人但是很有效。
错误 无法加载资源:net :: ERR_FILE_NOT_FOUND
我的最后一次尝试
load() {
this.liveProvider.load().then((data) => {
this.urlStrean = "http://evcv.mm.uol.com.br:1935/band/terraviva/playlist.m3u8";//this.getSafeUrl(data.result.url);
this.getSafeUrl(this.urlStrean);
console.log(this.urlStrean);
}).catch((error) => {
console.log(error);
})
}
getSafeUrl(url) {
return this.sanitizer.bypassSecurityTrustUrl(url);
}
在我看来:
<video width="100%" controls autoplay>
<source [src]="urlStrean" type="application/x-mpegURL">
</video>
答案 0 :(得分:0)
我用以下代码解决了问题:
constructor(public navCtrl: NavController, private liveProvider: LiveProvider, public sanitizer: DomSanitizer) {
this.liveProvider.load().then((data) => {
this.obj = sanitizer.bypassSecurityTrustResourceUrl(data.result.url);
// this.obj = sanitizer.bypassSecurityTrustResourceUrl("http://evcv.mm.uol.com.br:1935/band/terraviva/playlist.m3u8");
this.trustedUrl = this.obj;
}).catch((error) => {
console.log(error);
})