Chrome 如何在Angular14中播放blob视频(avi,mov)?

5us2dqdw  于 2023-08-01  发布在  Go
关注(0)|答案(1)|浏览(109)

我有这个问题有一段时间了,但不知道如何解决它。
我发现了这个类似的问题:how to play blob video in angular。但问题是,即使是在answear演示不兼容“avi”,和“mov”。我使用的是最新版本的Chrome浏览器,它没有显示选定的视频。
在html模板文件上:

<input type="file" accept="video/*" (change)="onSelectedFile($event)">

<video 
  *ngIf="prev_url" 
  [src]="prev_url" 
  style="width:300px; height:300px;" 
  controls></video>

字符串
在ts文件上:

export class AppComponent  {
  prev_url : any;

  constructor(
    private sanitizer : DomSanitizer
  ) {}

  onSelectedFile(ev) {
    let file = ev.target.files[0];
    var URL = window.URL;
    this.prev_url = this.sanitizer.bypassSecurityTrustUrl(URL.createObjectURL(file));
    console.log(this.prev_url)
  }
}


这里的工作sample
我也试过一个“vg播放器”,但是没有用。

ev7lccsx

ev7lccsx1#

export class AppComponent  {
  prev_url: SafeUrl;

  constructor(private sanitizer: DomSanitizer) {}

  onSelectedFile(ev) {
    let file = ev.target.files[0];
    var URL = window.URL;
    this.prev_url = this.sanitizer.bypassSecurityTrustUrl(URL.createObjectURL(file));
    console.log(this.prev_url);
  }
}

字符串

相关问题