work on player

This commit is contained in:
bkfox
2019-08-15 12:43:10 +02:00
parent e0f1ac498f
commit abaccf9ded
35 changed files with 17936 additions and 185 deletions

37
assets/js/liveInfo.js Normal file
View File

@@ -0,0 +1,37 @@
export default class {
constructor(url, timeout) {
this.url = url;
this.timeout = timeout;
this.promise = null;
this.items = [];
}
drop() {
this.promise = null;
}
fetch() {
const promise = fetch(this.url).then(response =>
response.ok ? response.json()
: Promise.reject(response)
).then(data => {
this.items = data;
return this.items
})
this.promise = promise;
return promise;
}
refresh() {
const promise = this.fetch();
promise.then(data => {
if(promise != this.promise)
return [];
window.setTimeout(() => this.refresh(), this.timeout*1000)
})
return promise
}
}