Can't play audio from firebase storage on Safari

156 Views Asked by At

I am making a website with Angular and Firebase and I need to play an m4a audio file from my Firebase storage bucket. I am using a Javascript Audio object to do this and while it works perfectly on Chrome gives this error on Safari:

Cancelled load to [Link] because it violates the resource's Cross-Origin-Resource-Policy response header.

Here is the code that plays the audio.

teacher = new Audio("https://storage.cloud.google.com/bucket-name.appspot.com/audiotest.m4a");

play() {
  let that = this;

  this.teacher.play();

  this.teacher.addEventListener("ended", function() {
    that.end = true;
  });
}

And the button to play the audio

<div *ngIf="!end" style="background-color: red;" class="btn" (click)="play()">
  <p class="box-text">Play</p>
</div>

I have tried adding COOR headers to my storage bucket but nothing changed.

I also tried making a video tag that played video from the same storage bucket and had the same effect. It worked on Chrome but not on Safari.

0

There are 0 best solutions below