34 lines
1017 B
JavaScript
34 lines
1017 B
JavaScript
import { C as Core } from './core-DnNOMtZn.js';
|
|
import { c as coreOpts, m as mount, u as uiOpts } from './opts-BtLxsM_6.js';
|
|
import { D as DummyLogger } from './logging--P0CsEu_.js';
|
|
|
|
function create(src, elem) {
|
|
let opts = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
const logger = opts.logger ?? new DummyLogger();
|
|
const core = new Core(src, coreOpts(opts, {
|
|
logger
|
|
}));
|
|
const {
|
|
el,
|
|
dispose
|
|
} = mount(core, elem, uiOpts(opts, {
|
|
logger
|
|
}));
|
|
const ready = core.init();
|
|
const player = {
|
|
el,
|
|
dispose,
|
|
getCurrentTime: () => ready.then(core.getCurrentTime.bind(core)),
|
|
getDuration: () => ready.then(core.getDuration.bind(core)),
|
|
play: () => ready.then(core.play.bind(core)),
|
|
pause: () => ready.then(core.pause.bind(core)),
|
|
seek: pos => ready.then(() => core.seek(pos))
|
|
};
|
|
player.addEventListener = (name, callback) => {
|
|
return core.addEventListener(name, callback.bind(player));
|
|
};
|
|
return player;
|
|
}
|
|
|
|
export { create };
|