-
Notifications
You must be signed in to change notification settings - Fork 23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
svelte kit window is not defined #15
Comments
First and foremost, I recommend SvelteKit over plain svelte. SvelteKit is a svelte extension that simplifies routing and includes features that plain svelte does not, such as layouts. SvelteKit uses (SSR) server-side rendering by default. Yes, windows work on SvelteKit without an adapter; however, you must add the window on the built-in svelte function, onMount. If you wish to use windows as freely as you do in svelte (SPA). You must install @sveltejs/adapter-static
|
You can disable server-side rendering on the page you use the video player. // +page.js
export const ssr = false; You can also import the component in <!-- +page.svelte -->
<script>
import { onMount } from 'svelte';
let VideoPlayer;
const poster = 'https://res.cloudinary.com/dvm02rtnk/image/upload/c_scale,w_1024,q_auto/v1628058523/blender/HERO_Blender_Grease_Pencil_Showcase_g86hfo.jpg';
const source = [
'https://res.cloudinary.com/dvm02rtnk/video/upload/v1628057414/blender/HERO_Blender_Grease_Pencil_Showcase_1080p_ctsjpy.mp4',
'https://res.cloudinary.com/dvm02rtnk/video/upload/v1628057414/blender/HERO_Blender_Grease_Pencil_Showcase_1080p_ctsjpy.webm',
'https://res.cloudinary.com/dvm02rtnk/video/upload/v1628057414/blender/HERO_Blender_Grease_Pencil_Showcase_1080p_ctsjpy.ogv',
];
onMount(async () => {
const component = await import('svelte-video-player');
VideoPlayer = component.default;
});
</script>
<svelte:component this={VideoPlayer} {poster} {source} /> |
does this work for SvelteKit?
The text was updated successfully, but these errors were encountered: