0

我正在尝试从 API 绑定视频中的 url,但我在下面遇到了这个错误,我尝试了 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>
4

1 回答 1

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);
    })
于 2017-11-07T13:08:53.870 回答