43 lines
1.1 KiB
JavaScript
43 lines
1.1 KiB
JavaScript
|
|
import { VideoPlayerRuntime, } from "../core";
|
||
|
|
// Angular-friendly wrapper around framework-agnostic runtime.
|
||
|
|
export class AngularVideoPlayerAdapter {
|
||
|
|
constructor() {
|
||
|
|
this.runtime = new VideoPlayerRuntime();
|
||
|
|
this.input = {};
|
||
|
|
}
|
||
|
|
async attach(container, input) {
|
||
|
|
this.input = { ...input };
|
||
|
|
const runtime = await this.runtime.init({
|
||
|
|
container,
|
||
|
|
...input,
|
||
|
|
});
|
||
|
|
return {
|
||
|
|
input: this.input,
|
||
|
|
runtime,
|
||
|
|
};
|
||
|
|
}
|
||
|
|
async update(nextInput) {
|
||
|
|
this.input = {
|
||
|
|
...this.input,
|
||
|
|
...nextInput,
|
||
|
|
};
|
||
|
|
const runtime = await this.runtime.update(nextInput);
|
||
|
|
return {
|
||
|
|
input: this.input,
|
||
|
|
runtime,
|
||
|
|
};
|
||
|
|
}
|
||
|
|
on(event, handler) {
|
||
|
|
return this.runtime.on(event, handler);
|
||
|
|
}
|
||
|
|
destroy() {
|
||
|
|
this.runtime.dispose();
|
||
|
|
}
|
||
|
|
getState() {
|
||
|
|
return {
|
||
|
|
input: this.input,
|
||
|
|
runtime: this.runtime.getState(),
|
||
|
|
};
|
||
|
|
}
|
||
|
|
}
|
||
|
|
//# sourceMappingURL=index.js.map
|