Reputation: 615
I have this code:
public playAudio(pathToFile: string): void {
const audio = new Audio();
audio.autoplay = true;
audio.src = `${environment.serverUrl}/${pathToFile}`;
audio.load();
audio.play();
}
It treggered by button click, something like this:
<button class="btn-pronounce"
(click)="playAudio(pathToFile)">
</button>
It works fine in chrome and firefox but in safari it doesn't work. Why?
Upvotes: 0
Views: 628
Reputation: 615
One of desicion is using this library: https://github.com/rserota/wad
Code still almost the same:
import Wad from 'web-audio-daw';
public playAudio(pathToFile: string): void {
const bell = new Wad({source: `${environment.serverUrl}/pronunciation-files/{pathToFile}`});
bell.play();
bell.stop();
}
But it isn't work in Angualr universal, because this library using windows.
Upvotes: 1