Hi all,
I use HTMLAudioElement to play audio. But when I 'npm start' or 'ng build ..', there is a problem. "Property 'then' does not exist on type 'void'."
Please help me.
Code below (https://googlechrome.github.io/samples/play-return-promise/):
playAudio(src: any) {
let audio: HTMLAudioElement = this.player.nativeElement;
audio.src = src;
// audio.load();
if (this.isPlay === false) {
var playPromise = audio.play();
if (playPromise !== undefined) {
playPromise.then(function () {
// Automatic playback started!
}).catch(function (error) {
// Automatic playback failed.
// Show a UI element to let the user manually start playback.
});
}
this.isPlay = true;
audio.onended = function () {
this.isPlay = false;
}.bind(this);
} else {
audio.pause();
this.isPlay = false;
}
}