mirror of
https://github.com/motion-canvas/motion-canvas.git
synced 2026-01-12 15:28:03 -05:00
fix: fix player state not being saved (#85)
This commit is contained in:
@@ -15,6 +15,23 @@ function renderRoot(vnode: ComponentChild) {
|
||||
|
||||
export function editor(project: Project) {
|
||||
const player = new Player(project);
|
||||
const playerKey = `${project.name}/player`;
|
||||
const frameKey = `${project.name}/frame`;
|
||||
const state = localStorage.getItem(playerKey);
|
||||
const frame = localStorage.getItem(frameKey);
|
||||
if (state) {
|
||||
player.loadState(JSON.parse(state));
|
||||
}
|
||||
if (frame) {
|
||||
player.requestSeek(parseInt(frame));
|
||||
}
|
||||
player.onStateChanged.subscribe(state => {
|
||||
localStorage.setItem(playerKey, JSON.stringify(state));
|
||||
});
|
||||
player.onFrameChanged.subscribe(frame => {
|
||||
localStorage.setItem(frameKey, frame.toString());
|
||||
});
|
||||
|
||||
document.title = `${project.name} | Motion Canvas`;
|
||||
renderRoot(
|
||||
<PlayerProvider player={player}>
|
||||
|
||||
Reference in New Issue
Block a user