Closed leroybm closed 9 months ago
@fpfcarvalho @brunopick @ZentoDH Could you guys take a look at this when possible? I've created a PR to fix it #788
@fpfcarvalho @brunopick @ZentoDH ping
@leroybm I'll take a look at this tomorrow. Sorry about that, it got lost in the holidays and some huge tickets.
@ZentoDH Thanks! Just pinged in case you missed it :)
Hi guys! Going to try it with the latest Nextjs. Any dates on release?
@dmdb I haven't got a specific date for you, but I'm pushing for this to be released for next week or the week after. CC: @leroybm
@leroybm @dmdb This is now released. Could you guys confirm if this fixed the issue?
@ZentoDH I just follow that https://docs.fluidplayer.com/docs/integration/react/ and I still get the same error "SyntaxError: Cannot use import statement outside a module .... /node_modules/fluid-player/src/index.js (30)"
@leroybm @dmdb This is now released. Could you guys confirm if this fixed the issue?
Thanks! I was using @leroybm branch with fix since then and had no issues on nextjs 14.0.4
@dmdb do you mind to share your code (player component) ? I am on the same version of nextjs and I cant make it work at all.
@dmdb do you mind to share your code (player component) ? I am on the same version of nextjs and I cant make it work at all.
/* eslint-disable react-hooks/exhaustive-deps -- debug */
/* eslint-disable @typescript-eslint/no-unnecessary-condition -- debug */
/* eslint-disable jsx-a11y/media-has-caption -- debug */
'use client';
import fluidPlayer from 'fluid-player';
import { useEffect, useRef } from 'react';
export default function FluidExample() {
const self = useRef(null);
let player: FluidPlayerInstance | null = null;
useEffect(() => {
if (!player && self.current) {
player = fluidPlayer(self.current, {
layoutControls: {
fillToContainer: true,
primaryColor: '#ffc700',
},
});
}
}, []);
return (
<video ref={self}>
<source
src="https://cdn.fluidplayer.com/videos/valerian-1080p.mkv"
data-fluid-hd
title="1080p"
type="video/mp4"
/>
</video>
);
}
@dmdb I still get this "Cannot use import statement outside a module" error but thank you I will investigate.
This was deployed last Friday, @tahola @dmdb maybe using the latest version will make it work?
The project that I was building was this one FYI https://github.com/berTrindade/video-player-manager
@leroybm I am using 3.31.0 and I cant even import it :
node_modules/fluid-player/src/index.js:30 import './polyfills'; ^^^^^^ SyntaxError: Cannot use import statement outside a module
Maybe I am doing something wrong.
@tahola You probably need to add the fluid-player to transpilePackages like so.
My next.config.js looks like the following and I stopped getting the error
/** @type {import('next').NextConfig} */
const nextConfig = {
reactStrictMode: false,
transpilePackages: ['fluid-player'],
}
module.exports = nextConfig
Hope it helps 🤞
@joelclaudio that was it, thank you. @leroybm I confirm that everything is working now, thank you.
This specific issue is fixed for me, I'm still having problem with the styling but It's probably on my side.
@ZentoDH @brunopick Thank you and the EXADS team for taking a look at this, feel free to close the issue
Thanks a mill @leroybm for the help! Closing...
Describe the bug When trying to implement Fluid Player in a Next.js project, the build fails due to trying to access the
window
object in the server side. This issue remains even when using"use client"
as the code runs on import, and imports always run in the server with Next.js.I've created a Pull Request that fixes this by using
globalThis
instead ofwindow
in theindex.js
andpolyfills.js
file.To Reproduce Steps to reproduce the behavior:
npm run dev
and check the buildExpected behavior Fluid Player should work as normal in the client.
Screenshots or Links Live website: https://codesandbox.io/p/devbox/objective-moon-5w6wcs?file=%2F.codesandbox%2Ftasks.json (You may need to refresh since codesandbox is a bit buggy) Fix PR: https://github.com/fluid-player/fluid-player/pull/788
Desktop (please complete the following information if relevant):
Affected version v3.29.0
Additional context To test locally, fetch the code and run
npm link
in the fluid-player project, thennpm link fluid-player
in the Next.js project.