In my Angular application, I'm opening a WAV file in browser and want to play it in the browser. The following code works in Chrome and Firefox, but in Edge v41 I get error on statement of this.audioElement.src = this.audioSrcURL;
:
ERROR Error: Invalid argument. [object Error]: {description: "Invalid argument.", message: "Invalid argument.", ngDebugContext: Object, ngErrorLogger: function() { [native code] }, number: -2147024809...}
ERROR CONTEXT [object Object] [object Object]: {component: Object, componentRenderElement: Object, context: Object, elDef: Object, elOrCompView: Object...}
My code is:
<audio #myAudio controls controlsList="nodownload">
<source src="" type="audio/x-wav" />
</audio>
@ViewChild('myAudio', { static: true }) myAudio: any;
audioElement: HTMLAudioElement;
audioSrcURL: string;
ngOnInit() {
this.audioElement = this.myAudio.nativeElement;
}
createObjectURL(inputFile: File): void {
if (window.URL && window.URL.createObjectURL) {
this.audioSrcURL = window.URL.createObjectURL(inputFile);
this.audioElement.src = this.audioSrcURL; // ---> ERROR HERE
}
}
Why do I get error "Invalid argument." ? What could be going wrong with this is Edge browser?