@huluvu424242/honey-slideshow
Version:
Text to Speech component wich is reading texts from DOM elements.
28 lines (27 loc) • 953 B
JavaScript
import { Subject } from "rxjs";
export class Fileloader {
constructor(fileURL) {
this.responseInfo = { content: null, status: null };
this.url = fileURL;
}
static of(fileURL) {
return new Fileloader(new URL(fileURL));
}
loadFile() {
const responseInfo = this.responseInfo;
const subject = new Subject();
const client = new XMLHttpRequest();
client.addEventListener("load", (event) => {
responseInfo.content = client.responseText;
console.log(event.total + " bytes gelesen.\n:" + responseInfo.content);
});
client.onloadend = function () {
responseInfo.status = client.status;
console.log("Response Status:" + responseInfo.status);
subject.next(responseInfo);
};
client.open("GET", this.url.toString());
client.send();
return subject;
}
}